I use compiled Heist. My splices only do run-time work (no load-time work). I have a template.tpl
like this:
<html>
<head>
<title><titleSplice/></title>
</head>
<body>
<bodySplice/>
</body>
</html>
This is how I do things:
- Within the Snap action for a
/:param
route, I userenderTemplate heistState "template"
to obtain aMyHeistRuntimeMonad Builder
. - I can pass the
:param
value to my splice by putting it into my runtime monad via ReaderT:type MyHeistRuntimeMonad = ReaderT String IO
. (Where theString
is for the passed in:param
value.)
And that is my problem. The only way to pass data from my routes to my splices is through the heist runtime monad. This makes things a bit complicated. My questions:
- Is there no alternative to
renderTemplate
that allows me to pass data directly to the template? For example, something like this:renderTemplate' "template" [("titleSplice", "myTitle"), ("bodySplice", "myBody")]
. - If this is not possible, why not? I'm just wondering why things were designed the way they were. I don't quite get it.