I recently upgraded the version of Heist I'm using. It was mostly an arbitrary decision and I'm still seeing the consequences of that action, mostly in terms of more pleasing code structure.
But, I was relying pretty heavily on the "apply" tag inside my templates in order to bring in boilerplate components, like my site header and menus. For me, a typical template looks like this:
<html>
<head>
<title> <PageTitle /> </title>
<link rel="stylesheet" type="text/css" href="/styles/style.css" />
<link rel="alternate" type="application/rss+xml" title="${PageTitle} Feed" href="http://www.savannidgerinel.com/rss" />
</head>
<body class="center">
<apply template="header" />
<div id="content">
<h1><PageTitle /></h1>
<ul>
<PageMetadata />
</ul>
<PageContent />
</div>
</body>
</html>
And, I'm now loading the templates like this:
setup_heist template_dir = do
templates <- Heist.loadTemplates template_dir
hs <- Heist.initHeist (Heist.HeistConfig [] [] [] [] templates)
return hs
This is not too much different from how I used to load templates (still using the loadTemplates
function), but it is a different way of setting up the Heist state that I'm not accustomed to.
But, now none of the apply
tags have any effect. My "included" templates just never load and within the resulting HTML I see this:
<apply template='header'></apply>
The apply tag is a splice just like any other. It doesn't have any special status other than that it is included with Heist. Therefore, you have to bind that splice in your HeistConfig. If you are using interpreted templates, then you can do it like this:
HeistConfig defaultInterpretedSplices [] [] [] templates
If you are using compiled templates, then use this:
HeistConfig [] defaultLoadTimeSplices [] [] templates
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With