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

Already on GitHub? Sign in to your account

Would Like to Be Able to Control Classes, IDs, Rel and Data Attributes on Both the List Item and Link Anchor #1

Closed
lynnwallenstein opened this Issue Mar 27, 2012 · 2 comments

Comments

Projects
None yet
2 participants

I am using twitter bootstrap's drop down JS for a navigation menu and want to use Goose to generate the links for me. In order to do so i need to be able to control the classes and data attributes on not only the list items (which I can do currently) but also the link it generates.

My source: https://gist.github.com/2219236

What it currently generates using Goose: https://gist.github.com/2219265

What I need it to generate to work: https://gist.github.com/2219279

... basically I need to add class="dropdown-toggle" data-toggle="dropdown" to the link anchor, however I also still need to leep the class of dropdown on the list item.

@bruce bruce closed this in 2d4976c Apr 30, 2012

Owner

bruce commented Apr 30, 2012

Now if you dont pass a URL parameter it won't try to make a link for you, and you can create it how you like at the top of your nav_to block, e.g. modifying your original:

<ul class="nav">
  <li class="vertical-divider"></li>
  <%= nav_to ('Home', root_path) %>
  <%= nav_to ('Docs', docs_path) %>
  <%= nav_to "Coding Styles"  do %>
    <%= link_to "Coding Styles", "#", 'data-toggle' => 'dropdown', :class => "dropdown" %>
    <ul class="dropdown-menu">
      <%= nav_to "CSS/Sass", :controller => "coding_styles", :action => "css" %>
      <%= nav_to "HTML", :controller => "coding_styles", :action => "html" %>
      <%= nav_to "JavaScript/CoffeeScript", :controller => "coding_styles", :action => "javascript" %>
      <%= nav_to "Ruby", :controller => "coding_styles", :action => "ruby" %>
    </ul>
    <% end %>
</ul>

Unfortunately there's some duplication ("Coding Styles" ... "Coding Styles") since nav_to uses the text for determining the active item (as passed to nav_at), but we can work on making the API better for this edge case. I'm reticent to just support passing two ad hoc customization hashes to nav_to (for the wrapper element and link), but I'm also aware the single config file approach is a bit too inflexible for complex interfaces.

Let me know if the above in HEAD works for you and I'll push a new release.

Worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment