Search code examples
haskell-snap-framework

Snap: Heist templates path


How can I change the default templates path?

The initialization function takes path relative to "projectroot/snaplets/heist" Which is heistInit "templates". So I end up with templates located in "projectroot/snaplets/heist/templates"

I would like my templates in "projectroot/resources/templates" instead. Is this possible? How do I pass it to the initializer?

Thanks


Solution

  • You can't. Snaplets have to use that directory hierarchy otherwise they won't be fully composable...i.e. what would happen if your app was sub-snaplet of another application. When we first released snaplets, we actually did it the way that you're asking for here. It seemed fine until we tried more complex snaplet hierarchies. If you want to simplify the default as much as possible, you can use heistInit "", which will as you noted store your templates in snaplets/heist.

    If you REALLY want to put your templates there, you could add that to the Heist snaplet as another template location using the function addTemplatesAt. But you can't prevent the Heist snaplet's initializer from also looking in snaplets/heist.