Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Template = Template {}
- template :: [TemplateElement] -> Template
- templateBodyCompiler :: Compiler (Item Template)
- templateCompiler :: Compiler (Item Template)
- applyTemplate :: Template -> Context a -> Item a -> Compiler (Item String)
- applyTemplate' :: forall a. [TemplateElement] -> Context a -> Item a -> Compiler String
- loadAndApplyTemplate :: Identifier -> Context a -> Item a -> Compiler (Item String)
- applyAsTemplate :: Context String -> Item String -> Compiler (Item String)
- readTemplate :: String -> Template
- unsafeReadTemplateFile :: FilePath -> Compiler Template
- module Hakyll.Web.Template.Internal.Element
- module Hakyll.Web.Template.Internal.Trim
Documentation
Datatype used for template substitutions.
template :: [TemplateElement] -> Template Source #
Wrap the constructor to ensure trim is called.
:: [TemplateElement] | Unwrapped Template |
-> Context a | Context |
-> Item a | Page |
-> Compiler String | Resulting item |
:: Identifier | Template identifier |
-> Context a | Context |
-> Item a | Page |
-> Compiler (Item String) | Resulting item |
The following pattern is so common:
tpl <- loadBody "templates/foo.html" someCompiler >>= applyTemplate tpl context
That we have a single function which does this:
someCompiler >>= loadAndApplyTemplate "templates/foo.html" context
It is also possible that you want to substitute $key$
s within the body of
an item. This function does that by interpreting the item body as a template,
and then applying it to itself.
readTemplate :: String -> Template Source #