Can anyone give an example of when HAML would be used in the 'real world'? I can't imagine it filling a niche that isn't covered by any of the other templating languages: what would seem most ideal is a combination of say, Jinja and HAML.
Can anyone give an example of when HAML would be used in the 'real world'? I can't imagine it filling a niche that isn't covered by any of the other templating languages: what would seem most ideal is a combination of say, Jinja and HAML.
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:
<%= render @items %>
items/_item.html.erb: <%= tag "fieldset", data: { id: item.id, category: item.category } %>For instance: try making an html element with a long list of attributes and see how it looks. Or worse, run a translate on a block of text while maintaining reasonable line lengths.
Good? Yes. Silver bullet html replacement? Lol.
<div attr1="val1, the first one"
attr2="val2, maybe this one is much longer"
attr3="you see where I'm going with this"
attr4="and so on...."
>
Div content goes here
</div>
What do you mean by "run a translate" though?I like it in my projects mostly for how clean and easy it is to read. It takes a little bit to get used to initially but it is worth it.
BTW, both Haml and Sass go very nicely with Sinatra... ;)
[0]: https://github.com/p/shpaml-jinja [1]: http://shpaml.webfactional.com/examples