10
09/2014
Haml 介绍
Haml (HTML abstraction markup language) is based on one primary principle: markup should be beautiful. It’s not just beauty for beauty’s sake either; Haml accelerates and simplifies template creation down to veritable haiku.
haml (html 抽象标识语言)的基本理念:标签应该更美观。…haml 能快速并且简化地写出名副其实的排比句 :(
看例子
这是 .erb 的写法
<section class=”container”>
<h1><%= post.title %></h1>
<h2><%= post.subtitle %></h2>
<div class=”content”>
<%= post.content %>
</div>
</section>
这是 haml 的
%section.container
%h1= post.title
%h2= post.subtitle
.content
= post.content
这是 .erb 的写法
<div class='item' id='item<%= item.id %>'> <%= item.body %> </div>
这是 haml 的
.item{:id => "item#{item.id}"}= item.body