hakyll-4.9.5.0: A static website compiler library

Safe Haskell | None
Language | Haskell98

Hakyll.Web.Template.Internal

Synopsis

- newtype Template = Template {
  - unTemplate :: [TemplateElement]
  }
- 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

newtype Template #

Datatype used for template substitutions.

Constructors

Template |
Fields unTemplate :: [TemplateElement]

Instances

Eq Template # |
Methods (==) :: Template -> Template -> Bool # (/=) :: Template -> Template -> Bool #
Show Template # |
Methods showsPrec :: Int -> Template -> ShowS # show :: Template -> String # showList :: [Template] -> ShowS #
IsString Template # |
Methods fromString :: String -> Template #
Binary Template # |
Methods put :: Template -> Put # get :: Get Template # putList :: [Template] -> Put #
Writable Template # |
Methods write :: FilePath -> Item Template -> IO () #

template :: [TemplateElement] -> Template #

Wrap the constructor to ensure trim is called.

templateBodyCompiler :: Compiler (Item Template) #

Read a template, without metadata header

templateCompiler :: Compiler (Item Template) #

Read complete file contents as a template

applyTemplate #

Arguments

:: Template | Template
-> Context a | Context
-> Item a | Page
-> Compiler (Item String) | Resulting item

applyTemplate' #

Arguments

:: [TemplateElement] | Unwrapped Template
-> Context a | Context
-> Item a | Page
-> Compiler String | Resulting item

loadAndApplyTemplate #

Arguments

:: 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

applyAsTemplate #

Arguments

:: Context String | Context
-> Item String | Item and template
-> Compiler (Item String) | Resulting item

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 #

unsafeReadTemplateFile :: FilePath -> Compiler Template #

module Hakyll.Web.Template.Internal.Element

module Hakyll.Web.Template.Internal.Trim