heist-0.12.0: An Haskell template system supporting both HTML5 and XML.

Safe Haskell | None

Heist.Splices.Json

Synopsis

- bindJson :: (ToJSON a, Monad n) => a -> Splice n

# Documentation

bindJson :: (ToJSON a, Monad n) => a -> Splice n

This splice binds convenience tags for the given JSON (or JSON-convertible) value and runs the tag's child nodes using the new bindings.

Tags bound when you pass in an object

Tags bound for an object looking like this:

     { "k_1": v_1, ..., "k_N": v_N }

`<value:{k_i}>` -- treats v_i as text `<snippet:{k_i}>` -- treats v_i as HTML `<with:{k_i}>` -- explodes v_i and runs its children

`<value var="foo.bar.baz"/>` -- walks the JSON tree to find "foo.bar.baz", and interprets it as a string `<snippet var="foo.bar.baz"/>` `<with var="foo.bar.baz">...<with>`

Tags bound when you pass in anything else

`<value/>` -- the given JSON value, as a string `<snippet/>` -- the given JSON value, parsed and spliced in as HTML