hakyll-4.16.2.0: A static website compiler library

Safe Haskell | Safe-Inferred
Language | Haskell2010

Hakyll.Web.Template.Internal

Synopsis

- data Template = Template {
  - tplElements :: [TemplateElement]
  - tplOrigin :: FilePath
  }
- template :: FilePath -> [TemplateElement] -> Template
- templateBodyCompiler :: Compiler (Item Template)
- templateCompiler :: Compiler (Item Template)
- applyTemplate :: Template -> Context a -> Item a -> Compiler (Item String)
- loadAndApplyTemplate :: Identifier -> Context a -> Item a -> Compiler (Item String)
- applyAsTemplate :: Context String -> Item String -> Compiler (Item String)
- readTemplate :: String -> Template
- compileTemplateItem :: Item String -> Compiler Template
- unsafeReadTemplateFile :: FilePath -> Compiler Template
- module Hakyll.Web.Template.Internal.Element
- module Hakyll.Web.Template.Internal.Trim

# Documentation

data Template Source #

Datatype used for template substitutions.

Constructors

Template |

Fields

- tplElements :: [TemplateElement]
- tplOrigin :: FilePath

#### Instances

Instances details

IsString Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Methods fromString :: String -> Template Source #
Generic Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Associated Types type Rep Template :: Type -> Type Source # Methods from :: Template -> Rep Template x Source # to :: Rep Template x -> Template Source #
Show Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Methods showsPrec :: Int -> Template -> ShowS Source # show :: Template -> String Source # showList :: [Template] -> ShowS Source #
Binary Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Methods put :: Template -> Put Source # get :: Get Template Source # putList :: [Template] -> Put Source #
Eq Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Methods (==) :: Template -> Template -> Bool Source # (/=) :: Template -> Template -> Bool Source #
Writable Template Source # |
Instance details Defined in Hakyll.Web.Template.Internal Methods write :: FilePath -> Item Template -> IO () Source #
type Rep Template Source # |

Instance details

Defined in Hakyll.Web.Template.Internal

type Rep Template = D1 ('MetaData "Template" "Hakyll.Web.Template.Internal" "hakyll-4.16.2.0-8eCr76LxdOJCzgCDfUmbD4" 'False) (C1 ('MetaCons "Template" 'PrefixI 'True) (S1 ('MetaSel ('Just "tplElements") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TemplateElement]) :*: S1 ('MetaSel ('Just "tplOrigin") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))

template :: FilePath -> [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

Interpolate template expressions from context values in a page

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 #

Deprecated: Use templateCompiler instead

Parse a string into a template. You should prefer `compileTemplateItem` over this.

compileTemplateItem :: Item String -> Compiler Template Source #

Parse an item body into a template. Provides useful error messages in the `Compiler` monad.

unsafeReadTemplateFile :: FilePath -> Compiler Template Source #

Deprecated: Use templateCompiler

module Hakyll.Web.Template.Internal.Element

module Hakyll.Web.Template.Internal.Trim