{-# LANGUAGE QuasiQuotes #-} -- | A simplist template language using a quasi-quoting approach. -- Hako quasi-quote expressions return a 'Html', which can -- be converted back to a 'String' using 'fromHtml'. -- Basic syntax rules: -- * Text is kept as-is, without any encoding performed. -- -- >>> [hako|
foobar
|] -- Html "foobar
" -- -- * Curly braces designate Haskell expressions, which must return an instance -- of typeclass 'ToHtml'; the 'toHtml' method is called automatically. -- -- >>> [hako|This is {"quoted"}|] -- Html "This is <a>quoted</a>" -- -- * If the opening curly brace is immediately followed by the keyword def, -- then the expression is interpreted as a definition instead; it works -- pretty much exactly like a function or constant definition in plain old -- Haskell, and the definition thus created can be called as a function from -- anywhere within the template. -- -- >>> [hako|{def a x ={x}}Here's a {a "link"}.|] -- Html "Here's a link." -- -- * A @def@ block can be used before it is defined. -- -- >>> [hako|Here's a {a "link"}.{def a x ={x}]|] -- Html "Here's a link." -- -- * As is to be expected from a quasi-quoter, the current scope is carried -- into the template. -- -- >>> let txt = "Hello, world!" in [hako|