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 asimple
stack template:
stack new working-with-splice simple
- Add a dependency on the heist library in the
build-depends
sub-section of theexecutable
section. In addition, also add a dependency on additional libraries required for this recipe. In addition totext
,bytestring
,lens
, andxmlhtml
, also add thetime
library:
executable working-with-splice hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: ...