I am having difficulty getting my helper to display a list item. The markup looks like the following:
- @bars.each do |bar|
<% display_bar(bar) %>
The actual helper looks like the following:
module MyHelper
def display_bar(bar)
type = bar.type
concat(%li.type)
concat(%b some text)
concat(%i some more text)
end
end
What am I doing wrong here?
<%won’t show you anyting. You’re in Haml. It’s ERb stuff (but even there it wouldn’t have shown anything: you’d forgotten the=sign, it should have been<%=).concat(%li.type): you cant put your markup inside your Ruby code. Ruby knows nothing about your%li“code”.Take a look:
UPD:
content_tag_forsets styles/ids for eachlitag based on the current model instance that makes it easy to implement styling/scripting in the future.