I have been following a short tutorial to build a tab menu on my application.
This is menu_builder method in Applciation_helper
def menu_builder(page_id)
tabs = ['events','locations','account']
content = ""
tabs.each do |tab|
content << if page_id == tab
content_tag('li', content_tag('a', tab, :href => nil ), :class => 'active')
else
content_tag('li', content_tag('a', tab, :href => "/#{tab}" ), :class => 'inactive')
end
end
content_tag(:ul, content, :class => 'tabnav')
end
application.html.haml
%nav
= menu_builder(@page_id)
And this is the source code that outputs
<nav>
<ul class="tabnav"><li class="active"><a>events</a></li><li class="inactive"><a href="/locations">locations</a></li><li class="inactive"><a href="/account">account</a></li></ul>
</nav>
I have playing around with haml_tag and so, but cannot figure how to make the menu_builder method output the correct syntax.
Try to replace:
with: