|
|
|
|
|
by AlwaysBCoding
4887 days ago
|
|
I'm finding that it's a lot cleaner to use with Javascript. For example, say you have an array of items and you want to create a fieldset for each item, and add an attribute of "data-id", and "data-category" to each fieldset so you can grab them with jQuery later on. In HAML all you have to do is this... - @items.each do |item| %fieldset{:data => {:id => item.id, :category => item.category}}
===In ERB the equivalent would be... <% @items.each do |item| %> <fieldset data-id="<%= item.id %>" data-category="<%= item.category %>">
</fieldset>
<% end %>=== It's a lot cleaner in HAML, especially extrapolated out over larger views. |
|
ERB view:
items/_item.html.erb: