[web-devel] rendering hamlet (esp julius) manually

Michael Snoyman michael at snoyman.com
Sat Jan 1 22:01:20 CET 2011

On Fri, Dec 31, 2010 at 2:31 PM, Max Cantor <mxcantor at gmail.com> wrote:
> I was wondering how to render a hamlet template (I'm specifically interested in julius - more on that later) outside of the context of a Handler handling a web request.  The reason I want to do this is I have come client side javascript (for android and ios + phonegap) and it would be nice to use julius to automatically generate some javascript code for the xcode project.  To be specific, i have a .js file like this:
> var URL_HOME = "http://localhost";
> // var URL_HOME = "http://myhost";
> var URL_PROFILE = URL_HOME + "/boo";
> If its possible to render julius without a request, then I could do this:
> var URL_HOME = @HomeR@;
> var URL_PROFILE = @ProfileR@;
> and add a small executable to generate the JS file.
> So, how would one do this?
> Sorry if this is obvious, i spent some time trying and digging around the haddocks, didn't find an answer.
> happy new years,
> max

Well, the first thing you'd want to look at is renderJulius[1]. For
that to work, you'll need the URL rendering function, which is what I
assume you're asking for, and is slightly harder to get. For that,
you'll probably want the joinPath method of the Yesod typeclass. Let
me know if you have trouble, I can (at a later date) write up an


[1] http://hackage.haskell.org/packages/archive/hamlet/

More information about the web-devel mailing list