weppos / tabs_on_rails

Tabs on Rails is a simple Rails plugin for creating and managing tabs and navigation menus.
https://simonecarletti.com/code/tabs-on-rails
MIT License
294 stars 52 forks source link

Dynamic tabs #6

Closed jgrau closed 13 years ago

jgrau commented 13 years ago

This is more a question than a bug so this might not be the best place to post. Anyways: is there a way use this library with dynamic content? Something like:

Haml (pseudo) code: = tabs_tag do |tab|

weppos commented 13 years ago

The following should work

= tabs_tag do |tab|
     - Page.roots.each do |page|
       = tab.send(page.permalink, page_path(page.permalink))
weppos commented 13 years ago

Sorry, ignore the previous answer. Your code won't work because it doesn't have any tab identifier.

See

<% tabs_tag do |tab| %>
  <%= tab.home      'Homepage', root_path %>
  <%= tab.dashboard 'Dashboard', dashboard_path %>
  <%= tab.account   'Account', account_path %>
<% end %>

You need at least one additional property, that is the name of the tab.

= tabs_tag do |tab|
     - Page.roots.each do |page|
       = tab.send("name", "Label", page_path(page.permalink))
jgrau commented 13 years ago

Works perfectly. In my app it translated to: = tabs_tag(:builder => MenuTabBuilder) do |tab|

And in the controller set_tab @page.permalink

Thanks you! Marking as closed

jgrau commented 13 years ago

-s :)

jgrau commented 13 years ago

oh, and for the record: the custom builder has nothing to do with this issue