[web-devel] Hamlet variables: (foo bar) baz or foo (bar baz)

Michael Snoyman michael at snoyman.com
Fri Dec 31 07:57:01 CET 2010

I thought I would start this in a separate thread. Right now in
Hamlet, $foo.bar.baz$ (or equivalently $foo bar baz$ gets converted to
the Haskell code "foo (bar baz)". This makes a fair bit of sense for
the period-delimited syntax, but feels very wrong for the
space-delimited syntax. So the question is: should we change things
around? That would mean we would need to modify our current templates
to include extra parentheses, eg:

    $foo.bar.baz$ -> $foo (bar baz)$
    $a.b.c.d$ -> $a (b (c d))$

I suppose that, in theory, if we actually change the variable
interpolation character to a percent sign, we could take back the
dollar sign to work like Haskell, eg:

    $a.b.c.d$ -> %a $ b $ c d%

And just since I brought *that* up: we could consider using a
different symbol for variable interpolation than the percent sign,
such as a hash or ampersand. However, both of those already have
special meaning (hash == id, ampersand == HTML escape character), so I
don't know how well that would work. There was talk once upon a time
of merging the syntax for dollar-sign and caret interpolation, which
now that we've added some more polymorphism it might be possible.

Caveat: I haven't actually written any code for this, so I don't know
how feasible it is. I'm basically throwing out ideas as they come to


More information about the web-devel mailing list