[web-devel] yesod's hamletFileDebug

Michael Snoyman michael at snoyman.com
Sun Jan 30 05:39:23 CET 2011


On Sun, Jan 30, 2011 at 12:37 AM, Rafael Cunha de Almeida
<rafael-lists at kontesti.me> wrote:
> Hello,
>
> I'm new to yesod and haskell web development in general. I read a bit
> about yesod and it looked nice. I thought it was really cool that I'd be
> able to view my changes to a template without recompiling, something
> I've always found very appealing in interpreted language's frameworks.
>
> However, after running yesod it created a Setting.hs file which uses
> H.cassiusFileDebug and H.juliusFileDebug for the purpose of dynamically
> generating such files, but hamlet files doesn't seem to work that way.
> Why was that changed? Am I to expect such feature will come back in the
> future? Or is already possible it just need to be set somewhere else?
>
> []'s
> Rafael

Hi Rafael,

I should probably document this properly somewhere. There are two
reasons I do not use hamletFileDebug in the scaffolded site:

* It does not handle Hamlet's polymorphism. A Hamlet template can be
converted to a type of Html, Hamlet or Widget, while hamletFileDebug
only works with Hamlet. In theory, this could be fixed.
* hamletFileDebug does not work at all when you add new variables to
the template. This is a problem that cannot be fixed.

The first issue does not affect Cassius and Julius since they do not
have any polymorphism. The second one is not as big a deal for Cassius
and Julius: it's simply not as common to interpolate variables in your
CSS and Javascript. I personally found that hamletFileDebug only
worked for me half the time.

Instead, a more robust solution is to use wai-handler-devel (also
included in the scaffolded site). This will automatically reinterpret
your app after a change to your Haskell or Hamlet template files. This
is usually very fast for small sites, but gets slow for large sites.
Hopefully in the near future, wai-handler-devel will switch from using
the hint package to the plugins package, which will help alleviate
that burden.

Michael



More information about the web-devel mailing list