Working with splice in Heist
In the previous recipe, we created a template and externally attached bindings to a tag, and rendered the template using these bindings. This is useful when we have simple bindings. But what if we have to do some calculation and bind the calculation to the tag, rather than a simple string binding? In this recipe, we will be binding a tag to the local time on the server (or actually, a place where the template will be rendered).
How to do it...
- Create a new project,
working-with-splice, with asimplestack template:
stack new working-with-splice simple
- Add a dependency on the heist library in the
build-dependssub-section of theexecutablesection. In addition, also add a dependency on additional libraries required for this recipe. In addition totext,bytestring,lens, andxmlhtml, also add thetimelibrary:
executable working-with-splice hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: ...