[web-devel] proposal for hamlet-like syntax that is more compatible with html

Alexandros Salazar nomothetis at gmail.com
Sun Dec 12 18:16:01 CET 2010

> I would like to note another possible benefit to the proposal noted by a
> commenter on Michael's blog- the removal of the '%' character means that
> instead of signifying variable interpolation with '$' it could be done with
> the '%', making the syntax uniform across hamlet, cassius, and julius.

True. On the other hand, it would break the similarity of Hamlet with jQuery
and other JS frameworks that identify ids with %. A trade-off, to be sure,
but one worth mentioning. I know I use a lot more identifiers than
interpolation in my julius, so it's easier for me to go "oh, right,
something is weird with interpolation."

> <snip context-switching, html-compatibiltiy>

I think Chris Smith made a good argument here: sometimes it's more annoying
to have to deal with a little quirk here and there than it is to have to
change completely.

> Space-based attributes:
> Are there any objection to the *concept* of the change to use a space with
> attributes instead of a '!'?. This would actually make hamlet *more* similar
> to HAML.

Yes, and I definitely would like that.

> The difficulty in implementation is with determining the end of the
> attribute portion of the tag. For '%body id=the-body' there would be
> ambiguity as to whether the id started an attribute or inner text. Even
> worse is an attribute without a value 'input type=checkbox checked'. One
> technique is to assume it is an attribute if an '=' sign is present-
> requiring escaping the '=' sign, and requiring a (possibly empty) value for
> every attribute. HAML handles attributes by requiring opening and closing
> symbole: '(attribute=name attribute2=name)', which looks nice, but I would
> much rather have white space to begin attributes, and the closing character
> is forced on you when there is no inner text.
> Following my original proposal, the attributes could have a closing
> character that is optional when there is no text.
>  %body id=the-body class=the-class>Inner Text

This is an interesting concept. Going back to Chris' argument, the opening
and closing symbols for the assignments will have the advantage that they
are expected. As an alternative, since this is Haskell we're talking about,
could we have *two* characters to signify the end, say "->"? I think it
would work nicely, as one can view a tag as "returning" its contents. I'm
still a fan of the opening and closing symbols, though.

It is my belief that with Hamlet we should stay as close to Haml as
consistent with taking advantage of the capabilities of Yesod. The names are
too similar to betray that expectation, so every difference should be for a
specific Yesod-related reason that people should find easy to remember. For
instance, different interpolating symbols for variables and type-safe URIs
makes sense, because type-safe URIs are an important Yesod feature.

Basically, if we reach an agreement that we would like a different, more
Yesod-specific templating language, I think we should seriously consider
forking Hamlet and calling it something else (Othello? :-) ). We could then
switch to supporting Othello full-time and deprecate Hamlet, but at least
people will not expect it to be like Haml.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20101212/23d653f0/attachment.htm>

More information about the web-devel mailing list