[web-devel] [hamlet] implicit spaces with newlines?

Patrick Brisbin pbrisbin at gmail.com
Thu May 19 23:32:52 CEST 2011

On 05/19/11 at 02:08pm, Greg Weber wrote:
> I am wondering if the default behavior should be changed in hamlet, because
> I find the white space issues a bit annoying myself. You end up with issues
> either way, but in Hamlet we have made html the default, so maybe white
> space behavior should be more closely aligned.

I agree with Greg that the more closely aligned with standard HTML, the 
better. Though, I don't really know the HTML standard well enough for my 
opinion to hold much weight...

I can, however, offer a slightly out-of-the-box solution I've been using 
when my hamlet seems to grow too far vertically due to inline tags.

It has the interesting side effect that your spacing intentions are more 
accurately passed through:

    -- I use Text and Widgets mostly, but this type signature could be 
    -- made more general I'm sure
    strong :: T.Text -> GWidget
    strong t = [hamlet|<strong>#{t}|]

Then you can just do:

    <p>hello ^{strong "there"}, how are you?

Awkward? Silly? Sure, but I find it more visually pleasing than:

        hello #
        , how are you?

Which can get exponentially worse (like when discussing something that 
requires <code> tags peppered throughout your paragraphs).


patrick brisbin

More information about the web-devel mailing list