rails content_tag nav builder helper -
rails content_tag nav builder helper -
sorry if sounds obvious i'm getting confused. i'm trying build navigation list helper.
at moment receives list of links array.
module applicationhelper def site_pages %w{index contact promotions} end def nav_builder list list.map |l| content_tag :li content_tag :a, :href => "#{l}_path" l end end end end end
but when run page ouput page array.
[<li><a href="index_path">index</a></li> <li><a href="about_path">about</a></li> <li><a href="contact_path">contact</a></li> <li><a href="promotions_path">promotions</a></li>]
instead of displaying list of links. there special do?
==edit==
i phone call builder way:
<%= nav_builder site_pages %>
the helper expected homecoming string of html, rather array. seek joining array elements single string:
def nav_builder list list.map |l| content_tag :li content_tag :a, :href => "#" "test" end end end.join("\n").html_safe end
ruby-on-rails helpers content-tag
Comments
Post a Comment