Always `$newline never` in Yesod

283 Views Asked by At

$newline never in Hamlet allows us to minify the HTML code. If we set it in a parent widget, it takes effect on it but not on the child widgets. So we have to set $newline never to all of the widgets when we want to minify the whole code. This isn't good.

Don't you know any better solutions? Thanks.

1

There are 1 best solutions below

1
On

You could define your own Hamlet quasi-quoter that defaults to NoNewlines in its HamletSettings, like the following (untested) code snippet:

import Text.Hamlet

myHamlet :: QuasiQuoter
myHamlet = hamletWithSettings hamletRules defaultHamletSettings{ hamletNewlines = NoNewlines}

and then simply use it as [myHamlet| ... |].