O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

In this recipe, rather than binding to a static string, we created a splice (which is a monadic computation). We created a binding between a tag and the splice, and inserted this binding into a HeistState. The templates that are rendered in the given HeistState will dynamically apply these bindings and call the splice to create a resultant template.

It is thus possible to embed an arbitrary computation, such as doing a database query, calling a backend microservice, and so on, and populate the template using the splices. In this recipe, we bound a <currenttime/> tag. The contents of this tag serve as an input to the splice. In this case, it is a time format in which the time should be output.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required