Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my "apply" tag no longer work in Heist 0.11.0.1?

Tags:

haskell

heist

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>
like image 680
Savanni D'Gerinel Avatar asked May 29 '13 18:05

Savanni D'Gerinel


1 Answers

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
like image 157
mightybyte Avatar answered Nov 13 '22 06:11

mightybyte