This page printed from:
panoptic.com/rking/Haml%2C+QED

For Our King, Only

Recent Changes / Heat / History

Haml, QED

Difference between revisions from 2012/10/10 14:55 and 2012/10/10 14:53.
Haml is a simple lib for generating XHTML/XML without specifying needless parts.

It can be intimidating at first glance, because it seems so unlike the HTMLish stuff you're used to. Let's prove its superiority one feature at a time (this is a shortened version of http://haml-lang.com/tutorial.html ).

# {{%atag^{a: b^}}} is better than {{<atag a="b">…</atag>}}
Let it be known that:
# {{%atag.aclass}} is better than {{%atag^{class: "aclass"^}}}
{{%atag^{a: b^}}} is better than {{<atag a="b">…</atag>}}
# {{%atag#an_id}} is better than {{%atag^{id: "an_id"^}}}
# {{#div_id}} is better than {{%div#div_id}}
{{%atag.aclass}} is better than {{%atag^{class: "aclass"^}}}
# {{= 3*2}} is better than {{<%= 3*2 %>}}
{{%atag#an_id}} is better than {{%atag^{id: "an_id"^}}}

{{#div_id}} is better than {{%div#div_id}}

{{= 3*2}} is better than {{<%= 3*2 %>}}

So, to put them together, compare the Erb of:

{{<div id="banner" class="shadowed" lang="en"><%= item.title %></div>}}

…versus the Haml of:

{{#banner.shadowed^{lang: 'en'^}= item.title}}

∎

! BTW

:markdown


Last changed: 2012/10/10 14:55