hakyll-4.9.8.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 Source #

Datatype used for template substitutions.

Constructors

Template |

Fields

- unTemplate :: [TemplateElement]

Instances

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

template :: [TemplateElement] -> Template Source #

Wrap the constructor to ensure trim is called.

templateBodyCompiler :: Compiler (Item Template) Source #

Read a template, without metadata header

templateCompiler :: Compiler (Item Template) Source #

Read complete file contents as a template

applyTemplate Source #

Arguments

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

applyTemplate' Source #

Arguments

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

loadAndApplyTemplate Source #

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 Source #

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 Source #

unsafeReadTemplateFile :: FilePath -> Compiler Template Source #

module Hakyll.Web.Template.Internal.Element

module Hakyll.Web.Template.Internal.Trim