In various forums and blogs, I see some people promoting HAML and some promoting HTML. What are the advantages and disadvantages of using HAML vs HTML?
I just want to understand what I'm missing out on if I use HAML in favor of HTML (if any).
Key differences are: Haml doesn't have both start and end for each element like eRuby. eRuby syntax looks a lot like HTML and is thereby more HTML-like while Haml is more CSS-like. Haml uses indentation to nest tag elements whereas eRuby uses the same HTML representation.
At its core, Haml is a lightweight markup language. Haml makes writing HTML much easier, and when I say “much easier” what I really mean is “you won't believe how much time you can save by using Haml.” In my opinion, it's even more of an obvious time saver than Sass.
In Haml, we write a tag by using the percent sign and then the name of the tag. This works for %strong , %div , %body , %html ; any tag you want. Then, after the name of the tag is = , which tells Haml to evaluate Ruby code to the right and then print out the return value as the contents of the tag.
What is it? 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.
The main disadvantage of using HAML over HTML is simply that HTML is just about universal among web developers, where as the HAML community is still a relatively small community. This would undoubtly make finding developers to work on your project in the future a more daunting task.
But if you have the resources, you could argue that to be an advantage. Ensuring you only hired developers that were capable and experience in HAML.
The other major down side I can see is that if you have graphics/web designers working on your templates, separate from your development team, they would also have to be familiar with HAML. As you can imagine there are very few graphics/web designers who capable of it, and few tools to help them.
You are trying to compare Apples to Oranges. Browsers only understand HTML. HAML is just a templating language that gets transformed into HTML (e.g. same final output). If you find the HAML syntax to be easier than HTML then go for it. However IMHO - abstracting away what actual elements you are generating just makes applying CSS and doing JavaScript navigation that much more difficult.
Personally if I wanted to "trim" my HTML, I would put content into tags (depends on your serverside technology)
<!doctype html>
<html>
<head>...</head>
<body>
<x:awesomeListThing data="$foo"/>
<x:foreach data="$bar">
<x:renderBazWidget/>
</x:foreach>
<div>random content that hasn't been "tagified" yet.</div>
</body>
</html>
Then inside any tag's template you'll be able to see the actual HTML structure that is being generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With