Hacker News new | ask | show | jobs
by barkmadley 5364 days ago
actually the attribute syntax leaves a lot to be desired in terms of redundancy. First you have to quote the attributes (or put a : in front of them?), yuck. you need to use the => operator which is two times too big, and whats with the unnecessary outer braces?

non-idiomatic hamlet isn't far from that haml snippet (note you would never put bits of urls in the template as strings, instead you provide a url rendering function which converts the @{} bits into url strings):

    <#gallery
      <.screenshots
      <ul
        <li
          <a href=@{View first}
idiomatic hamlet is much more focused on being a cleaner html for designers than it is trying to be a haml clone.
1 comments

> actually the attribute syntax leaves a lot to be desired in terms of redundancy.

I agree. Considering that you can assign 'id' and 'class' through the main syntax, I don't think it's too bad. Attribute values are Ruby strings, so the quotes work for me. With Ruby 1.9 you should, in theory, be able to use the new improved hash syntax:

    a{href: "/ding"}
...but I don't know if HAML has implemented it.

Edit: HAML actually supports a different, simpler syntax for attributes:

    %a(href="/ding")
> idiomatic hamlet is much more focused on being a cleaner html for designers than it is trying to be a haml clone.

I know that some companies work that way. We let our designers learn HAML (and SASS) instead. That way they can contribute to the projects as first-class citizens. HAML is simple enough that a designer can even work with conditionals and loops.