Dynamic tabs
jgrau opened this issue · 5 comments
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|
- Page.roots.each do |page|
= tab.(page.permalink), page_path(page.permalink)
The following should work
= tabs_tag do |tab|
- Page.roots.each do |page|
= tab.send(page.permalink, page_path(page.permalink))
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))
Works perfectly. In my app it translated to:
= tabs_tag(:builder => MenuTabBuilder) do |tab|
- Page.in_menu.roots.each do |page|
= tab.send(page.permalink, page.title, page_path(page.permalink))
And in the controller
set_tab @page.permalink
Thanks you! Marking as closed
-s :)
oh, and for the record: the custom builder has nothing to do with this issue