heist-1.1.0.1: An Haskell template system supporting both HTML5 and XML.

Safe Haskell | None
Language | Haskell98

Heist.Internal.Types

Description

Internal types and accessors. There are no guarantees that heist will preserve backwards compatibility for symbols in this module. If you use them, no complaining when your code breaks.

Synopsis

- type Splices s = MapSyntax Text s
- type Template = [Node]
- type MIMEType = ByteString
- type TPath = [ByteString]
- data DocumentFile = DocumentFile {
  - dfDoc :: Document
  - dfFile :: Maybe FilePath
  }
- data Markup
  - = Xml
  - | Html
- newtype RuntimeSplice m a = RuntimeSplice {
  - unRT :: StateT HeterogeneousEnvironment m a
  }
- data Chunk m
  - = Pure !ByteString
  - | RuntimeHtml !(RuntimeSplice m Builder)
  - | RuntimeAction !(RuntimeSplice m ())
- showChunk :: Chunk m -> String
- isPureChunk :: Chunk m -> Bool
- type AttrSplice m = Text -> RuntimeSplice m [(Text, Text)]
- data SpliceError = SpliceError {
  - spliceHistory :: [(TPath, Maybe FilePath, Text)]
  - spliceTemplateFile :: Maybe FilePath
  - visibleSplices :: [Text]
  - contextNode :: Node
  - spliceMsg :: Text
  }
- spliceErrorText :: SpliceError -> Text
- data CompileException = forall e.Exception e => CompileException {
  - originalException :: e
  - exceptionContext :: [SpliceError]
  }
- data HeistState m = HeistState {
  - _spliceMap :: HashMap Text (HeistT m m Template)
  - _templateMap :: HashMap TPath DocumentFile
  - _compiledSpliceMap :: HashMap Text (HeistT m IO (DList (Chunk m)))
  - _compiledTemplateMap :: !(HashMap TPath ([Chunk m], MIMEType))
  - _attrSpliceMap :: HashMap Text (AttrSplice m)
  - _recurse :: Bool
  - _curContext :: TPath
  - _splicePath :: [(TPath, Maybe FilePath, Text)]
  - _recursionDepth :: Int
  - _doctypes :: [DocType]
  - _curTemplateFile :: Maybe FilePath
  - _keygen :: KeyGen
  - _preprocessingMode :: Bool
  - _curMarkup :: Markup
  - _splicePrefix :: Text
  - _spliceErrors :: [SpliceError]
  - _errorNotBound :: Bool
  - _numNamespacedTags :: Int
  }
- newtype HeistT n m a = HeistT {
  - runHeistT :: Node -> HeistState n -> m (a, HeistState n)
  }
- templateNames :: HeistState m -> [TPath]
- compiledTemplateNames :: HeistState m -> [TPath]
- spliceNames :: HeistState m -> [Text]
- compiledSpliceNames :: HeistState m -> [Text]
- evalHeistT :: Monad m => HeistT n m a -> Node -> HeistState n -> m a
- _liftCatch :: (m (a, HeistState n) -> (e -> m (a, HeistState n)) -> m (a, HeistState n)) -> HeistT n m a -> (e -> HeistT n m a) -> HeistT n m a
- _liftCallCC :: ((((a, HeistState n) -> m (b, HeistState n)) -> m (a, HeistState n)) -> m (a, HeistState n)) -> ((a -> HeistT n m b) -> HeistT n m a) -> HeistT n m a
- getParamNode :: Monad m => HeistT n m Node
- localParamNode :: Monad m => (Node -> Node) -> HeistT n m a -> HeistT n m a
- getsHS :: Monad m => (HeistState n -> r) -> HeistT n m r
- getHS :: Monad m => HeistT n m (HeistState n)
- putHS :: Monad m => HeistState n -> HeistT n m ()
- modifyHS :: Monad m => (HeistState n -> HeistState n) -> HeistT n m ()
- restoreHS :: Monad m => HeistState n -> HeistT n m ()
- localHS :: Monad m => (HeistState n -> HeistState n) -> HeistT n m a -> HeistT n m a
- modRecursionDepth :: Monad m => (Int -> Int) -> HeistT n m ()
- incNamespacedTags :: Monad m => HeistT n m ()
- data AttAST
  - = Literal Text
  - | Ident Text
- isIdent :: AttAST -> Bool
- data HeistConfig m = HeistConfig {
  - _hcSpliceConfig :: SpliceConfig m
  - _hcNamespace :: Text
  - _hcErrorNotBound :: Bool
  }
- data SpliceConfig m = SpliceConfig {
  - _scInterpretedSplices :: Splices (Splice m)
  - _scLoadTimeSplices :: Splices (Splice IO)
  - _scCompiledSplices :: Splices (Splice m)
  - _scAttributeSplices :: Splices (AttrSplice m)
  - _scTemplateLocations :: [TemplateLocation]
  - _scCompiledTemplateFilter :: TPath -> Bool
  }
- type TemplateLocation = IO (Either [String] TemplateRepo)
- type TemplateRepo = HashMap TPath DocumentFile
- lens :: Functor f => (t1 -> t) -> (t1 -> a -> b) -> (t -> f a) -> t1 -> f b
- scInterpretedSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> SpliceConfig m -> f (SpliceConfig m)
- scLoadTimeSplices :: Functor f => (Splices (Splice IO) -> f (Splices (Splice IO))) -> SpliceConfig m -> f (SpliceConfig m)
- scCompiledSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> SpliceConfig m -> f (SpliceConfig m)
- scAttributeSplices :: Functor f => (Splices (AttrSplice m) -> f (Splices (AttrSplice m))) -> SpliceConfig m -> f (SpliceConfig m)
- scTemplateLocations :: Functor f => ([TemplateLocation] -> f [TemplateLocation]) -> SpliceConfig m -> f (SpliceConfig m)
- scCompiledTemplateFilter :: Functor f => ((TPath -> Bool) -> f (TPath -> Bool)) -> SpliceConfig m -> f (SpliceConfig m)
- hcSpliceConfig :: Functor f => (SpliceConfig m -> f (SpliceConfig m)) -> HeistConfig m -> f (HeistConfig m)
- hcNamespace :: Functor f => (Text -> f Text) -> HeistConfig m -> f (HeistConfig m)
- hcErrorNotBound :: Functor f => (Bool -> f Bool) -> HeistConfig m -> f (HeistConfig m)
- hcInterpretedSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> HeistConfig m -> f (HeistConfig m)
- hcLoadTimeSplices :: Functor f => (Splices (Splice IO) -> f (Splices (Splice IO))) -> HeistConfig m -> f (HeistConfig m)
- hcCompiledSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> HeistConfig m -> f (HeistConfig m)
- hcAttributeSplices :: Functor f => (Splices (AttrSplice m) -> f (Splices (AttrSplice m))) -> HeistConfig m -> f (HeistConfig m)
- hcTemplateLocations :: Functor f => ([TemplateLocation] -> f [TemplateLocation]) -> HeistConfig m -> f (HeistConfig m)
- hcCompiledTemplateFilter :: Functor f => ((TPath -> Bool) -> f (TPath -> Bool)) -> HeistConfig m -> f (HeistConfig m)

# Documentation

type Splices s = MapSyntax Text s Source #

Convenient type alies for splices.

type Template = [Node] Source #

A `Template` is a forest of XML nodes. Here we deviate from the "single root node" constraint of well-formed XML because we want to allow templates to contain document fragments that may not have a single root.

type MIMEType = ByteString Source #

MIME Type. The type alias is here to make the API clearer.

type TPath = [ByteString] Source #

Reversed list of directories. This holds the path to the template currently being processed.

data DocumentFile Source #

Holds data about templates read from disk.

Constructors

DocumentFile |

Fields

- dfDoc :: Document
- dfFile :: Maybe FilePath

#### Instances

Instances details

Eq DocumentFile Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods (==) :: DocumentFile -> DocumentFile -> Bool (/=) :: DocumentFile -> DocumentFile -> Bool
Show DocumentFile Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods showsPrec :: Int -> DocumentFile -> ShowS show :: DocumentFile -> String showList :: [DocumentFile] -> ShowS

data Markup Source #

Designates whether a document should be treated as XML or HTML.

Constructors

Xml |
Html |

newtype RuntimeSplice m a Source #

Monad used for runtime splice execution.

Constructors

RuntimeSplice |

Fields

- unRT :: StateT HeterogeneousEnvironment m a

#### Instances

Instances details

MonadTrans RuntimeSplice Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods lift :: Monad m => m a -> RuntimeSplice m a
Monad m => Monad (RuntimeSplice m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods (>>=) :: RuntimeSplice m a -> (a -> RuntimeSplice m b) -> RuntimeSplice m b (>>) :: RuntimeSplice m a -> RuntimeSplice m b -> RuntimeSplice m b return :: a -> RuntimeSplice m a
Functor m => Functor (RuntimeSplice m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods fmap :: (a -> b) -> RuntimeSplice m a -> RuntimeSplice m b (<$) :: a -> RuntimeSplice m b -> RuntimeSplice m a
Monad m => Applicative (RuntimeSplice m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods pure :: a -> RuntimeSplice m a (<*>) :: RuntimeSplice m (a -> b) -> RuntimeSplice m a -> RuntimeSplice m b liftA2 :: (a -> b -> c) -> RuntimeSplice m a -> RuntimeSplice m b -> RuntimeSplice m c (*>) :: RuntimeSplice m a -> RuntimeSplice m b -> RuntimeSplice m b (<*) :: RuntimeSplice m a -> RuntimeSplice m b -> RuntimeSplice m a
MonadIO m => MonadIO (RuntimeSplice m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods liftIO :: IO a -> RuntimeSplice m a
(Monad m, Semigroup a) => Semigroup (RuntimeSplice m a) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods (<>) :: RuntimeSplice m a -> RuntimeSplice m a -> RuntimeSplice m a # sconcat :: NonEmpty (RuntimeSplice m a) -> RuntimeSplice m a stimes :: Integral b => b -> RuntimeSplice m a -> RuntimeSplice m a
(Monad m, Monoid a) => Monoid (RuntimeSplice m a) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods mempty :: RuntimeSplice m a mappend :: RuntimeSplice m a -> RuntimeSplice m a -> RuntimeSplice m a mconcat :: [RuntimeSplice m a] -> RuntimeSplice m a

data Chunk m Source #

Opaque type representing pieces of output from compiled splices.

Constructors

Pure !ByteString | output known at load time
RuntimeHtml !(RuntimeSplice m Builder) | output computed at run time
RuntimeAction !(RuntimeSplice m ()) | runtime action used only for its side-effect

#### Instances

Instances details

Show (Chunk m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods showsPrec :: Int -> Chunk m -> ShowS show :: Chunk m -> String showList :: [Chunk m] -> ShowS

showChunk :: Chunk m -> String Source #

isPureChunk :: Chunk m -> Bool Source #

type AttrSplice m = Text -> RuntimeSplice m [(Text, Text)] Source #

Type alias for attribute splices. The function parameter is the value of the bound attribute splice. The return value is a list of attribute key/value pairs that get substituted in the place of the bound attribute.

data SpliceError Source #

Detailed information about a splice error.

Constructors

SpliceError |

Fields

- spliceHistory :: [(TPath, Maybe FilePath, Text)]
- spliceTemplateFile :: Maybe FilePath
- visibleSplices :: [Text]
- contextNode :: Node
- spliceMsg :: Text

#### Instances

Instances details

Eq SpliceError Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods (==) :: SpliceError -> SpliceError -> Bool (/=) :: SpliceError -> SpliceError -> Bool
Show SpliceError Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods showsPrec :: Int -> SpliceError -> ShowS show :: SpliceError -> String showList :: [SpliceError] -> ShowS

spliceErrorText :: SpliceError -> Text Source #

Transform a SpliceError record to a Text message.

data CompileException Source #

Exception type for splice compile errors. Wraps the original exception and provides context. data (Exception e) => CompileException e = CompileException

Constructors

forall e.Exception e => CompileException |

Fields

- originalException :: e
- exceptionContext :: [SpliceError]

#### Instances

Instances details

Show CompileException Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods showsPrec :: Int -> CompileException -> ShowS show :: CompileException -> String showList :: [CompileException] -> ShowS
Exception CompileException Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods toException :: CompileException -> SomeException # fromException :: SomeException -> Maybe CompileException # displayException :: CompileException -> String #

data HeistState m Source #

Holds all the state information needed for template processing. You will build a `HeistState` using `initHeist` and any of Heist's `HeistState -> HeistState` "filter" functions. Then you use the resulting `HeistState` in calls to `renderTemplate`.

m is the runtime monad

Constructors

HeistState |

Fields

- _spliceMap :: HashMap Text (HeistT m m Template)

  A mapping of splice names to splice actions

- _templateMap :: HashMap TPath DocumentFile

  A mapping of template names to templates

- _compiledSpliceMap :: HashMap Text (HeistT m IO (DList (Chunk m)))

  A mapping of splice names to splice actions

- _compiledTemplateMap :: !(HashMap TPath ([Chunk m], MIMEType))

  A mapping of template names to templates , _compiledTemplateMap :: HashMap TPath (m Builder, MIMEType)

- _attrSpliceMap :: HashMap Text (AttrSplice m)
- _recurse :: Bool

  A flag to control splice recursion

- _curContext :: TPath

  The path to the template currently being processed.

- _splicePath :: [(TPath, Maybe FilePath, Text)]

  Stack of the splices used.

- _recursionDepth :: Int

  A counter keeping track of the current recursion depth to prevent infinite loops.

- _doctypes :: [DocType]

  The doctypes encountered during template processing.

- _curTemplateFile :: Maybe FilePath

  The full path to the current template's file on disk.

- _keygen :: KeyGen

  A key generator used to produce new unique Promises.

- _preprocessingMode :: Bool

  Flag indicating whether we're in preprocessing mode. During preprocessing, errors should stop execution and be reported. During template rendering, it's better to skip the errors and render the page.

- _curMarkup :: Markup

  This is needed because compiled templates are generated with a bunch of calls to renderFragment rather than a single call to render.

- _splicePrefix :: Text

  A prefix for all splices (namespace ++ ":").

- _spliceErrors :: [SpliceError]

  List of errors encountered during splice processing.

- _errorNotBound :: Bool

  Whether to throw an error when a tag wih the heist namespace does not correspond to a bound splice. When not using a namespace, this flag is ignored.

- _numNamespacedTags :: Int

newtype HeistT n m a Source #

HeistT is the monad transformer used for splice processing. HeistT intentionally does not expose any of its functionality via MonadState or MonadReader functions. We define passthrough instances for the most common types of monads. These instances allow the user to use HeistT in a monad stack without needing calls to `lift`.

`n` is the runtime monad (the parameter to HeistState).

`m` is the monad being run now. In this case, "now" is a variable concept. The type `HeistT n n` means that "now" is runtime. The type `HeistT n IO` means that "now" is `IO`, and more importantly it is NOT runtime. In Heist, the rule of thumb is that `IO` means load time and `n` means runtime.

Constructors

HeistT |

Fields

- runHeistT :: Node -> HeistState n -> m (a, HeistState n)

#### Instances

Instances details

MonadBase b m => MonadBase b (HeistT n m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods liftBase :: b α -> HeistT n m α Source #
MonadBaseControl b m => MonadBaseControl b (HeistT n m) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Associated Types type StM (HeistT n m) a Source # Methods liftBaseWith :: (RunInBase (HeistT n m) b -> b a) -> HeistT n m a Source # restoreM :: StM (HeistT n m) a -> HeistT n m a Source #
MonadError e m => MonadError e (HeistT n m) Source # | MonadError passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods throwError :: e -> HeistT n m a catchError :: HeistT n m a -> (e -> HeistT n m a) -> HeistT n m a
MonadReader r m => MonadReader r (HeistT n m) Source # | MonadReader passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods ask :: HeistT n m r local :: (r -> r) -> HeistT n m a -> HeistT n m a reader :: (r -> a) -> HeistT n m a
MonadState s m => MonadState s (HeistT n m) Source # | MonadState passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods get :: HeistT n m s put :: s -> HeistT n m () state :: (s -> (a, s)) -> HeistT n m a
MonadTrans (HeistT n) Source # | MonadTrans instance
Instance details Defined in Heist.Internal.Types.HeistState Methods lift :: Monad m => m a -> HeistT n m a
MonadTransControl (HeistT n) Source # |
Instance details Defined in Heist.Internal.Types.HeistState Associated Types type StT (HeistT n) a Source # Methods liftWith :: Monad m => (Run (HeistT n) -> m a) -> HeistT n m a Source # restoreT :: Monad m => m (StT (HeistT n) a) -> HeistT n m a Source #
Monad m => Monad (HeistT n m) Source # | Monad instance
Instance details Defined in Heist.Internal.Types.HeistState Methods (>>=) :: HeistT n m a -> (a -> HeistT n m b) -> HeistT n m b (>>) :: HeistT n m a -> HeistT n m b -> HeistT n m b return :: a -> HeistT n m a
Functor m => Functor (HeistT n m) Source # | Functor instance
Instance details Defined in Heist.Internal.Types.HeistState Methods fmap :: (a -> b) -> HeistT n m a -> HeistT n m b (<$) :: a -> HeistT n m b -> HeistT n m a
MonadFix m => MonadFix (HeistT n m) Source # | MonadFix passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods mfix :: (a -> HeistT n m a) -> HeistT n m a
MonadFail m => MonadFail (HeistT n m) Source # | MonadFail instance
Instance details Defined in Heist.Internal.Types.HeistState Methods fail :: String -> HeistT n m a
(Monad m, Functor m) => Applicative (HeistT n m) Source # | Applicative instance
Instance details Defined in Heist.Internal.Types.HeistState Methods pure :: a -> HeistT n m a (<*>) :: HeistT n m (a -> b) -> HeistT n m a -> HeistT n m b liftA2 :: (a -> b -> c) -> HeistT n m a -> HeistT n m b -> HeistT n m c (*>) :: HeistT n m a -> HeistT n m b -> HeistT n m b (<*) :: HeistT n m a -> HeistT n m b -> HeistT n m a
(Functor m, MonadPlus m) => Alternative (HeistT n m) Source # | Alternative passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods empty :: HeistT n m a (<|>) :: HeistT n m a -> HeistT n m a -> HeistT n m a some :: HeistT n m a -> HeistT n m [a] many :: HeistT n m a -> HeistT n m [a]
MonadPlus m => MonadPlus (HeistT n m) Source # | MonadPlus passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods mzero :: HeistT n m a mplus :: HeistT n m a -> HeistT n m a -> HeistT n m a
MonadIO m => MonadIO (HeistT n m) Source # | MonadIO instance
Instance details Defined in Heist.Internal.Types.HeistState Methods liftIO :: IO a -> HeistT n m a
MonadCont m => MonadCont (HeistT n m) Source # | MonadCont passthrough instance
Instance details Defined in Heist.Internal.Types.HeistState Methods callCC :: ((a -> HeistT n m b) -> HeistT n m a) -> HeistT n m a
type StT (HeistT n) a Source # |
Instance details Defined in Heist.Internal.Types.HeistState type StT (HeistT n) a = (a, HeistState n)
type StM (HeistT n m) a Source # |
Instance details Defined in Heist.Internal.Types.HeistState type StM (HeistT n m) a = ComposeSt (HeistT n) m a

templateNames :: HeistState m -> [TPath] Source #

Gets the names of all the templates defined in a HeistState.

compiledTemplateNames :: HeistState m -> [TPath] Source #

Gets the names of all the templates defined in a HeistState.

spliceNames :: HeistState m -> [Text] Source #

Gets the names of all the interpreted splices defined in a HeistState.

compiledSpliceNames :: HeistState m -> [Text] Source #

Gets the names of all the compiled splices defined in a HeistState.

evalHeistT :: Monad m => HeistT n m a -> Node -> HeistState n -> m a Source #

Evaluates a template monad as a computation in the underlying monad.

_liftCatch :: (m (a, HeistState n) -> (e -> m (a, HeistState n)) -> m (a, HeistState n)) -> HeistT n m a -> (e -> HeistT n m a) -> HeistT n m a Source #

Helper for MonadError instance.

_liftCallCC :: ((((a, HeistState n) -> m (b, HeistState n)) -> m (a, HeistState n)) -> m (a, HeistState n)) -> ((a -> HeistT n m b) -> HeistT n m a) -> HeistT n m a Source #

Helper for MonadCont instance.

getParamNode :: Monad m => HeistT n m Node Source #

Gets the node currently being processed.

    <speech author="Shakespeare">
      To sleep, perchance to dream.
    </speech>

When you call `getParamNode` inside the code for the `speech` splice, it returns the Node for the `speech` tag and its children. `getParamNode >>= childNodes` returns a list containing one `TextNode` containing part of Hamlet's speech. `liftM (getAttribute "author") getParamNode` would return `Just "Shakespeare"`.

localParamNode :: Monad m => (Node -> Node) -> HeistT n m a -> HeistT n m a Source #

HeistT's `local`.

getsHS :: Monad m => (HeistState n -> r) -> HeistT n m r Source #

HeistT's `gets`.

getHS :: Monad m => HeistT n m (HeistState n) Source #

HeistT's `get`.

putHS :: Monad m => HeistState n -> HeistT n m () Source #

HeistT's `put`.

modifyHS :: Monad m => (HeistState n -> HeistState n) -> HeistT n m () Source #

HeistT's `modify`.

restoreHS :: Monad m => HeistState n -> HeistT n m () Source #

Restores the HeistState. This function is almost like putHS except it preserves the current doctypes and splice errors. You should use this function instead of `putHS` to restore an old state. This was needed because doctypes needs to be in a "global scope" as opposed to the template call "local scope" of state items such as recursionDepth, curContext, and spliceMap.

localHS :: Monad m => (HeistState n -> HeistState n) -> HeistT n m a -> HeistT n m a Source #

Abstracts the common pattern of running a HeistT computation with a modified heist state.

modRecursionDepth :: Monad m => (Int -> Int) -> HeistT n m () Source #

Modifies the recursion depth.

incNamespacedTags :: Monad m => HeistT n m () Source #

Increments the namespaced tag count

data AttAST Source #

AST to hold attribute parsing structure. This is necessary because attoparsec doesn't support parsers running in another monad.

Constructors

Literal Text |
Ident Text |

#### Instances

Instances details

Show AttAST Source # |
Instance details Defined in Heist.Internal.Types.HeistState Methods showsPrec :: Int -> AttAST -> ShowS show :: AttAST -> String showList :: [AttAST] -> ShowS

isIdent :: AttAST -> Bool Source #

data HeistConfig m Source #

Constructors

HeistConfig |

Fields

- _hcSpliceConfig :: SpliceConfig m

  Splices and templates

- _hcNamespace :: Text

  A namespace to use for all tags that are bound to splices. Use empty string for no namespace.

- _hcErrorNotBound :: Bool

  Whether to throw an error when a tag wih the heist namespace does not correspond to a bound splice. When not using a namespace, this flag is ignored.

data SpliceConfig m Source #

The splices and templates Heist will use. To bind a splice simply include it in the appropriate place here.

Constructors

SpliceConfig |

Fields

- _scInterpretedSplices :: Splices (Splice m)

  Interpreted splices are the splices that Heist has always had. They return a list of nodes and are processed at runtime.

- _scLoadTimeSplices :: Splices (Splice IO)

  Load time splices are like interpreted splices because they return a list of nodes. But they are like compiled splices because they are processed once at load time. All of Heist's built-in splices should be used as load time splices.

- _scCompiledSplices :: Splices (Splice m)

  Compiled splices return a DList of Chunks and are processed at load time to generate a runtime monad action that will be used to render the template.

- _scAttributeSplices :: Splices (AttrSplice m)

  Attribute splices are bound to attribute names and return a list of attributes.

- _scTemplateLocations :: [TemplateLocation]

  A list of all the locations that Heist should get its templates from.

- _scCompiledTemplateFilter :: TPath -> Bool

  Predicate function to control which templates to compile. Using templates filtered out with this is still possible via callTemplate.

#### Instances

Instances details

Semigroup (SpliceConfig m) Source # |
Instance details Defined in Heist.Internal.Types Methods (<>) :: SpliceConfig m -> SpliceConfig m -> SpliceConfig m # sconcat :: NonEmpty (SpliceConfig m) -> SpliceConfig m stimes :: Integral b => b -> SpliceConfig m -> SpliceConfig m
Monoid (SpliceConfig m) Source # |
Instance details Defined in Heist.Internal.Types Methods mempty :: SpliceConfig m mappend :: SpliceConfig m -> SpliceConfig m -> SpliceConfig m mconcat :: [SpliceConfig m] -> SpliceConfig m

type TemplateLocation = IO (Either [String] TemplateRepo) Source #

An IO action for getting a template repo from this location. By not just using a directory path here, we support templates loaded from a database, retrieved from the network, or anything else you can think of.

type TemplateRepo = HashMap TPath DocumentFile Source #

lens :: Functor f => (t1 -> t) -> (t1 -> a -> b) -> (t -> f a) -> t1 -> f b Source #

My lens creation function to avoid a dependency on lens.

scInterpretedSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for interpreted splices :: Simple Lens (SpliceConfig m) (Splices (I.Splice m))

scLoadTimeSplices :: Functor f => (Splices (Splice IO) -> f (Splices (Splice IO))) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for load time splices :: Simple Lens (SpliceConfig m) (Splices (I.Splice IO))

scCompiledSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for complied splices :: Simple Lens (SpliceConfig m) (Splices (C.Splice m))

scAttributeSplices :: Functor f => (Splices (AttrSplice m) -> f (Splices (AttrSplice m))) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for attribute splices :: Simple Lens (SpliceConfig m) (Splices (AttrSplice m))

scTemplateLocations :: Functor f => ([TemplateLocation] -> f [TemplateLocation]) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for template locations :: Simple Lens (SpliceConfig m) [TemplateLocation]

scCompiledTemplateFilter :: Functor f => ((TPath -> Bool) -> f (TPath -> Bool)) -> SpliceConfig m -> f (SpliceConfig m) Source #

Lens for compiled template filter :: Simple Lens (SpliceConfig m) (TBool -> Bool)

hcSpliceConfig :: Functor f => (SpliceConfig m -> f (SpliceConfig m)) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for the SpliceConfig :: Simple Lens (HeistConfig m) (SpliceConfig m)

hcNamespace :: Functor f => (Text -> f Text) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for the namespace :: Simple Lens (HeistConfig m) Text

hcErrorNotBound :: Functor f => (Bool -> f Bool) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for the namespace error flag :: Simple Lens (HeistConfig m) Bool

hcInterpretedSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for interpreted splices :: Simple Lens (HeistConfig m) (Splices (I.Splice m))

hcLoadTimeSplices :: Functor f => (Splices (Splice IO) -> f (Splices (Splice IO))) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for load time splices :: Simple Lens (HeistConfig m) (Splices (I.Splice IO))

hcCompiledSplices :: Functor f => (Splices (Splice m) -> f (Splices (Splice m))) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for compiled splices :: Simple Lens (HeistConfig m) (Splices (C.Splice m))

hcAttributeSplices :: Functor f => (Splices (AttrSplice m) -> f (Splices (AttrSplice m))) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for attribute splices :: Simple Lens (HeistConfig m) (Splices (AttrSplice m))

hcTemplateLocations :: Functor f => ([TemplateLocation] -> f [TemplateLocation]) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for template locations :: Simple Lens (HeistConfig m) [TemplateLocation]

hcCompiledTemplateFilter :: Functor f => ((TPath -> Bool) -> f (TPath -> Bool)) -> HeistConfig m -> f (HeistConfig m) Source #

Lens for compiled template filter :: Simple Lens (SpliceConfig m) (TBool -> Bool)