Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not rendering options: #14

Open
exocode opened this issue Aug 19, 2015 · 5 comments
Open

not rendering options: #14

exocode opened this issue Aug 19, 2015 · 5 comments

Comments

@exocode
Copy link

exocode commented Aug 19, 2015

What I'm doing wrong?

index.html.erb
<%= render_navigation :expand_all => true, :renderer => :bootstrap %>

navigation.rb

primary.item :index, "Title", index_path,  icon: 'icon-book', class: "my-class", id: "blah-id", data: "zack-boom"

I also restarted,...

@pdf
Copy link
Owner

pdf commented Aug 19, 2015

Where's the rest of your navigation.rb?

@exocode
Copy link
Author

exocode commented Aug 20, 2015

sorry, nothing special:

# -*- coding: utf-8 -*-
# Configures your navigation
SimpleNavigation::Configuration.run do |navigation|

  # Specify the class that will be applied to active navigation items. Defaults to 'selected'
  navigation.selected_class = 'current'

  navigation.items do |primary|
    primary.dom_class = 'list-inline text-right'
    primary.item :index, t('home'), index_path, options: {icon: :'glyphicons-home'}
    primary.item :company, t('company'), "#", icon: 'glyphicons-group'
    primary.item :contact, t('contact'), contact_path, icon: 'glyphicons-message-empty'
    primary.item :shop, t('shop'), "#", icon: 'glyphicons-shopping-cart'

    # Specify a custom renderer if needed.
    # The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
    # The renderer can also be specified as option in the render_navigation call.
    #navigation.renderer = Your::Custom::Renderer

    # Specify the class that will be applied to the current leaf of
    # active navigation items. Defaults to 'simple-navigation-active-leaf'
    navigation.active_leaf_class = 'current'

    # Specify if item keys are added to navigation items as id. Defaults to true
    #navigation.autogenerate_item_ids = true

    # You can override the default logic that is used to autogenerate the item ids.
    # To do this, define a Proc which takes the key of the current item as argument.
    # The example below would add a prefix to each key.
    #navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}

    # If you need to add custom html around item names, you can define a proc that
    # will be called with the name you pass in to the navigation.
    # The example below shows how to wrap items spans.
    #navigation.name_generator = Proc.new {|name, item| "<span>#{name}</span>"}

    # Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
    #navigation.auto_highlight = true

    # Specifies whether auto highlight should ignore query params and/or anchors when
    # comparing the navigation items with the current URL. Defaults to true
    #navigation.ignore_query_params_on_auto_highlight = true
    #navigation.ignore_anchors_on_auto_highlight = true

    # If this option is set to true, all item names will be considered as safe (passed through html_safe). Defaults to false.
    #navigation.consider_item_names_as_safe = false

    # Define the primary navigation

    # Add an item to the primary navigation. The following params apply:
    # key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
    # name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
    # url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
    # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
    #           some special options that can be set:
    #           :if - Specifies a proc to call to determine if the item should
    #                 be rendered (e.g. <tt>if: -> { current_user.admin? }</tt>). The
    #                 proc should evaluate to a true or false value and is evaluated in the context of the view.
    #           :unless - Specifies a proc to call to determine if the item should not
    #                     be rendered (e.g. <tt>unless: -> { current_user.admin? }</tt>). The
    #                     proc should evaluate to a true or false value and is evaluated in the context of the view.
    #           :method - Specifies the http-method for the generated link - default is :get.
    #           :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
    #                            when the item should be highlighted, you can set a regexp which is matched
    #                            against the current URI.  You may also use a proc, or the symbol <tt>:subpath</tt>.
    #

    # You can also specify a condition-proc that needs to be fullfilled to display an item.
    # Conditions are part of the options. They are evaluated in the context of the views,
    # thus you can use all the methods and vars you have available in the views.

    # you can also specify html attributes to attach to this particular level
    # works for all levels of the menu
    #primary.dom_attributes = {id: 'menu-id', class: 'menu-class'}

    # You can turn off auto highlighting for a specific level
    #primary.auto_highlight = false
  end
end

@pdf
Copy link
Owner

pdf commented Aug 20, 2015

Looks fair. do you get any elements in your dom? I'm away for the next week, so I'm afraid I won't be able to help you until then.

@exocode
Copy link
Author

exocode commented Aug 20, 2015

yes it gets rendered proberly exept the Ids, icons, classes:

<ul class="list-inline text-right">
    <li class="current current" id="index">
        <a href="/en/index" class="current">Home</a>
    </li>
    <li id="company">
        <a href="#">Company</a>
    </li>
    <li id="contact">
        <a href="/en/contact">Contact</a>
    </li>
    <li id="shop">
        <a href="#">
            <span class="translation_missing" title="translation missing: en.shop">Shop</span>
        </a>
    </li>
</ul>

@ninkibah
Copy link

I read the rendering code, and you have to put your options in a html hash:

primary.item :index, "Title", index_path,  html: {icon: 'icon-book', class: "my-class", id: "blah-id"}, data: "zack-boom"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants