Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seems easy enough:

HAML structure is really easy to understand. It attempts to strip out as much of the annoying HTML repetition as possible. For example to write paragraph tag you could use:

%p This is HTML paragraph. HAML will convert that to:

<p>This is HTML paragraph</p>

You can also pass more attributes to the tag you want:

.banners(id="top-banner", title="Your ad here") Your text here Will be rendered like this:

<div id="top-banner" class="banners" title="Your ad here">Your text here</div>



You don't need to close <p> tag, it closes automatically.

Also supporting something as simple as </> (close current tag) would significantly reduce HTML boilerplate without inventing new language. I agree that shortcuts for id and class are nice too.

My proposal:

  <div.content>
    <form#login>
      <input name=username>
      <input name=password>
    </>
  </>


That's almost SGML, except for the short form syntax for IDs:

    <div content>
      <form id=login>
        <input name=username>
        <input name=password>
      </>
    </>
Note though that including markup declarations for enumerating custom class names and for the input element having declared content EMPTY is required (the latter declaration actually part of HTML DTDs [1]):

   <!attlist div class (content) #implied>
   <!element input - - empty>
Moreover, in SGML you can have tag omission/inference, like on the p element or the html element itself.

Your "</>" Close current tag syntax is actually part of SGML (as is "<>" which is treated as start element tag for the most recently closed element), known as FEATURES MINIMIZE SHORTTAG ENDTAG EMPTY and FEATURES MINIMIZE SHORTTAG STARTTAG EMPTY features, resp. ([2]).

[1]: http://sgmljs.net/docs/w3c-html52-dtd.html

[2]: http://sgmljs.net/docs/sgmlrefman.html


  .banners(id="top-banner", title="Your ad here")
Minor correction: the comma there isn't valid Haml syntax, when you use parenthesis for attributes it expects the same format as inside a regular HTML tag (i.e. attributes separated by whitespace).

But you can also rewrite that as:

  #top-banner.banners(title="Your ad here")


IDK how closely HAML hews to valid HTML elements/attrs/etc., but DMark (https://denisdefreyne.github.io/d-mark/) is syntactically similar and very extensible.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: