5 ms·
James is right on about where HAML falls short; but thats not HAML's problem, its more of a preference. I will be the first to say that HAML is no appropriate f
by bradgessler 18y ago
James is right on about where HAML falls short; but thats not HAML's problem, its more of a preference. I will be the first to say that HAML is no appropriate for everything. Here is how I apply various templating engines in my Rails projects:
HAML - Great for application markup (as opposed to document markup... see ERB below) for a number of reasons. (1) application markup tends to be heavy in javascript where you need a clean DOM. HAML reduces the chance of screwing up the DOM and makes it easier to look at during development. (2) Lots of conditionals in the view and I'm too lazy to factor them out into partials or helpers. Sometimes its just easier to express if/then and loops in HAML than it is in ERB... slightly less markup.
ERB - Document/content markup. If I have big docs with lots of links and paragraphs, but nothing to heavy going on thats dynamic/conditional, ERB is the easiest way to go.
Mix 'n' match! Then you can have the best of both worlds!
- intranation 18y agoI have to say, as a professional web developer, that I've never found that "application markup tends to be heavy in javascript", or that I've "(screwed) up the DOM". HTML isn't particularly difficult, although things like HAML might prove that doing it well without a helper abstraction is difficult. Code management (breaking things up into appropriate templates and fragments) trumps things like HAML for ease of use and clean separation every time.