Rails generate HTML in custom helper -
i have following simplified helper works:
module myhelper def widget link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end end end
i output second link such as:
module myhelper def widget link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end link_to new_comment_path content_tag(:i, '', class: "fa fa-comment") end end end
the solution outlined in pugautomatic article uses "concat" concatenate multiple helpers within single block helper. http://thepugautomatic.com/2013/06/helpers/ works standard link_to helpers such as:
module myhelper def widget concat link_to("hello", hello_path) concat " " concat link_to("bye", goodbye_path) end end
when using glyphon in href need use link_to block helper such as:
link_to new_comment_path content_tag(:i, '', class: "fa fa-comment") end
concat not allow me concat multiple link_to block helpers such as:
module myhelper def widget concat link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end concat link_to new_comment_path content_tag(:i, '', class: "fa fa-comment") end end end
what solution in scenario?
i think have put each link_to separate method:
module myhelper def link_to_flag_page link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end end def link_to_new_comment link_to new_comment_path content_tag(:i, '', class: "fa fa-comment") end end end
and call them 1 one
Comments
Post a Comment