Copyright | Copyright (C) 2009-2019 John MacFarlane |
---|---|
License | BSD3 |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a
- class Monad m => TemplateMonad m where
- getPartial :: FilePath -> m Text
- newtype Context a = Context {}
- data Val a
- class ToContext a b where
- class FromContext a b where
- type TemplateTarget a = (HasChars a, ToText a, FromText a)
- data Template a
- data Variable = Variable {}
- data Pipe
- data Alignment
- data Border = Border {
- borderLeft :: Text
- borderRight :: Text
Documentation
renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a Source #
Render a compiled template in a "context" which provides values for the template's variables.
class Monad m => TemplateMonad m where Source #
A TemplateMonad
defines a function to retrieve a partial
(from the file system, from a database, or using a default
value).
getPartial :: FilePath -> m Text Source #
Instances
TemplateMonad IO Source # | |
Defined in Text.DocTemplates.Internal | |
TemplateMonad Identity Source # | |
Defined in Text.DocTemplates.Internal |
A Context
defines values for template's variables.
Instances
Functor Context Source # | |
Foldable Context Source # | |
Defined in Text.DocTemplates.Internal fold :: Monoid m => Context m -> m # foldMap :: Monoid m => (a -> m) -> Context a -> m # foldMap' :: Monoid m => (a -> m) -> Context a -> m # foldr :: (a -> b -> b) -> b -> Context a -> b # foldr' :: (a -> b -> b) -> b -> Context a -> b # foldl :: (b -> a -> b) -> b -> Context a -> b # foldl' :: (b -> a -> b) -> b -> Context a -> b # foldr1 :: (a -> a -> a) -> Context a -> a # foldl1 :: (a -> a -> a) -> Context a -> a # elem :: Eq a => a -> Context a -> Bool # maximum :: Ord a => Context a -> a # minimum :: Ord a => Context a -> a # | |
Traversable Context Source # | |
ToContext a (Context a) Source # | |
Data a => Data (Context a) Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Context a -> c (Context a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Context a) # toConstr :: Context a -> Constr # dataTypeOf :: Context a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Context a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Context a)) # gmapT :: (forall b. Data b => b -> b) -> Context a -> Context a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Context a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Context a -> r # gmapQ :: (forall d. Data d => d -> u) -> Context a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Context a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) # | |
Show a => Show (Context a) Source # | |
Semigroup (Context a) Source # | |
Monoid (Context a) Source # | |
TemplateTarget a => FromYAML (Context a) Source # | |
TemplateTarget a => ToYAML (Context a) Source # | |
Defined in Text.DocTemplates.Internal | |
TemplateTarget a => ToJSON (Context a) Source # | |
Defined in Text.DocTemplates.Internal | |
TemplateTarget a => FromJSON (Context a) Source # | |
A variable value.
Instances
Functor Val Source # | |
Foldable Val Source # | |
Defined in Text.DocTemplates.Internal fold :: Monoid m => Val m -> m # foldMap :: Monoid m => (a -> m) -> Val a -> m # foldMap' :: Monoid m => (a -> m) -> Val a -> m # foldr :: (a -> b -> b) -> b -> Val a -> b # foldr' :: (a -> b -> b) -> b -> Val a -> b # foldl :: (b -> a -> b) -> b -> Val a -> b # foldl' :: (b -> a -> b) -> b -> Val a -> b # foldr1 :: (a -> a -> a) -> Val a -> a # foldl1 :: (a -> a -> a) -> Val a -> a # elem :: Eq a => a -> Val a -> Bool # maximum :: Ord a => Val a -> a # | |
Traversable Val Source # | |
TemplateTarget a => FromContext a (Val a) Source # | |
ToContext a (Val a) Source # | |
Data a => Data (Val a) Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Val a -> c (Val a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Val a) # dataTypeOf :: Val a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Val a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a)) # gmapT :: (forall b. Data b => b -> b) -> Val a -> Val a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r # gmapQ :: (forall d. Data d => d -> u) -> Val a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Val a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # | |
Show a => Show (Val a) Source # | |
TemplateTarget a => FromYAML (Val a) Source # | |
TemplateTarget a => ToYAML (Val a) Source # | |
Defined in Text.DocTemplates.Internal | |
TemplateTarget a => ToJSON (Val a) Source # | |
Defined in Text.DocTemplates.Internal | |
TemplateTarget a => FromJSON (Val a) Source # | |
class ToContext a b where Source #
Instances
TemplateTarget a => ToContext a Value Source # | |
TemplateTarget a => ToContext a Bool Source # | |
TemplateTarget a => ToContext a a Source # | |
ToContext a b => ToContext a [b] Source # | |
ToContext a a => ToContext a (Doc a) Source # | |
ToContext a (Val a) Source # | |
ToContext a (Context a) Source # | |
ToContext a b => ToContext a (Map Text b) Source # | |
TemplateTarget [a] => ToContext [a] [a] Source # | |
class FromContext a b where Source #
The FromContext
class provides functions for extracting
values from Val
and Context
.
Instances
TemplateTarget a => FromContext a a Source # | |
FromContext a b => FromContext a [b] Source # | |
TemplateTarget a => FromContext a (Doc a) Source # | |
TemplateTarget a => FromContext a (Val a) Source # | |
TemplateTarget [a] => FromContext [a] [a] Source # | |
A template.
Interpolate Variable | |
Conditional Variable (Template a) (Template a) | |
Iterate Variable (Template a) (Template a) | |
Nested (Template a) | |
Partial [Pipe] (Template a) | |
Literal (Doc a) | |
Concat (Template a) (Template a) | |
Empty |
Instances
A variable which may have several parts (foo.bar.baz
).
Instances
Eq Variable Source # | |
Data Variable Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Variable -> c Variable # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Variable # toConstr :: Variable -> Constr # dataTypeOf :: Variable -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Variable) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variable) # gmapT :: (forall b. Data b => b -> b) -> Variable -> Variable # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Variable -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Variable -> r # gmapQ :: (forall d. Data d => d -> u) -> Variable -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Variable -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Variable -> m Variable # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Variable -> m Variable # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Variable -> m Variable # | |
Ord Variable Source # | |
Defined in Text.DocTemplates.Internal | |
Read Variable Source # | |
Show Variable Source # | |
Generic Variable Source # | |
Semigroup Variable Source # | |
Monoid Variable Source # | |
type Rep Variable Source # | |
Defined in Text.DocTemplates.Internal type Rep Variable = D1 ('MetaData "Variable" "Text.DocTemplates.Internal" "doctemplates-0.10.0.1-CSajvuX1NaGgqjKak8gA9" 'False) (C1 ('MetaCons "Variable" 'PrefixI 'True) (S1 ('MetaSel ('Just "varParts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "varPipes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pipe]))) |
ToPairs | |
ToUppercase | |
ToLowercase | |
ToLength | |
Reverse | |
FirstItem | |
LastItem | |
Rest | |
AllButLast | |
Chomp | |
ToAlpha | |
ToRoman | |
NoWrap | |
Block Alignment Int Border |
Instances
Eq Pipe Source # | |
Data Pipe Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pipe -> c Pipe # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pipe # dataTypeOf :: Pipe -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pipe) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pipe) # gmapT :: (forall b. Data b => b -> b) -> Pipe -> Pipe # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r # gmapQ :: (forall d. Data d => d -> u) -> Pipe -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Pipe -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pipe -> m Pipe # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pipe -> m Pipe # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pipe -> m Pipe # | |
Ord Pipe Source # | |
Read Pipe Source # | |
Show Pipe Source # | |
Generic Pipe Source # | |
type Rep Pipe Source # | |
Defined in Text.DocTemplates.Internal type Rep Pipe = D1 ('MetaData "Pipe" "Text.DocTemplates.Internal" "doctemplates-0.10.0.1-CSajvuX1NaGgqjKak8gA9" 'False) (((C1 ('MetaCons "ToPairs" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ToUppercase" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ToLowercase" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ToLength" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Reverse" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FirstItem" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LastItem" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Rest" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AllButLast" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Chomp" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ToAlpha" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ToRoman" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoWrap" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Block" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Alignment) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Border))))))) |
Instances
Eq Alignment Source # | |
Data Alignment Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Alignment -> c Alignment # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Alignment # toConstr :: Alignment -> Constr # dataTypeOf :: Alignment -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Alignment) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment) # gmapT :: (forall b. Data b => b -> b) -> Alignment -> Alignment # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Alignment -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Alignment -> r # gmapQ :: (forall d. Data d => d -> u) -> Alignment -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Alignment -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # | |
Ord Alignment Source # | |
Defined in Text.DocTemplates.Internal | |
Read Alignment Source # | |
Show Alignment Source # | |
Generic Alignment Source # | |
type Rep Alignment Source # | |
Defined in Text.DocTemplates.Internal type Rep Alignment = D1 ('MetaData "Alignment" "Text.DocTemplates.Internal" "doctemplates-0.10.0.1-CSajvuX1NaGgqjKak8gA9" 'False) (C1 ('MetaCons "LeftAligned" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Centered" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RightAligned" 'PrefixI 'False) (U1 :: Type -> Type))) |
Border | |
|
Instances
Eq Border Source # | |
Data Border Source # | |
Defined in Text.DocTemplates.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Border -> c Border # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Border # toConstr :: Border -> Constr # dataTypeOf :: Border -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Border) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Border) # gmapT :: (forall b. Data b => b -> b) -> Border -> Border # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r # gmapQ :: (forall d. Data d => d -> u) -> Border -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Border -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Border -> m Border # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Border -> m Border # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Border -> m Border # | |
Ord Border Source # | |
Read Border Source # | |
Show Border Source # | |
Generic Border Source # | |
type Rep Border Source # | |
Defined in Text.DocTemplates.Internal type Rep Border = D1 ('MetaData "Border" "Text.DocTemplates.Internal" "doctemplates-0.10.0.1-CSajvuX1NaGgqjKak8gA9" 'False) (C1 ('MetaCons "Border" 'PrefixI 'True) (S1 ('MetaSel ('Just "borderLeft") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "borderRight") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |