Copyright | © 2016–2017 Stack Buliders |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov@openmailbox.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Text.Microstache.Type
Description
Types used by the package. You don't usually need to import the module, because Text.Microstache re-exports everything you may need, import that module instead.
Synopsis
- data Template = Template {
- templateActual :: PName
- templateCache :: Map PName [Node]
- data Node
- newtype Key = Key {}
- showKey :: Key -> Text
- newtype PName = PName {}
- data MustacheException
- displayMustacheException :: MustacheException -> String
- data MustacheWarning
- displayMustacheWarning :: MustacheWarning -> String
Documentation
Mustache template as name of “top-level” template and a collection of all available templates (partials).
Template
is a Semigroup
. This means that you can combine Template
s
(and their caches) using the (
operator, the resulting <>
)Template
will have the same currently selected template as the left one. Union of
caches is also left-biased.
Constructors
Template | |
Fields
|
Instances
Data Template # | |||||
Defined in Text.Microstache.Type Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Template -> c Template # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Template # toConstr :: Template -> Constr # dataTypeOf :: Template -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Template) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Template) # gmapT :: (forall b. Data b => b -> b) -> Template -> Template # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Template -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Template -> r # gmapQ :: (forall d. Data d => d -> u) -> Template -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Template -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Template -> m Template # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Template -> m Template # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Template -> m Template # | |||||
Semigroup Template # | |||||
Generic Template # | |||||
Defined in Text.Microstache.Type Associated Types
| |||||
Show Template # | |||||
Eq Template # | |||||
Ord Template # | |||||
Defined in Text.Microstache.Type | |||||
type Rep Template # | |||||
Defined in Text.Microstache.Type type Rep Template = D1 ('MetaData "Template" "Text.Microstache.Type" "microstache-1.0.2.3-DwZkw7U9d9640vqKYO1sOg" 'False) (C1 ('MetaCons "Template" 'PrefixI 'True) (S1 ('MetaSel ('Just "templateActual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PName) :*: S1 ('MetaSel ('Just "templateCache") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PName [Node])))) |
Structural element of template.
Constructors
TextBlock Text | Plain text contained between tags |
EscapedVar Key | HTML-escaped variable |
UnescapedVar Key | Unescaped variable |
Section Key [Node] | Mustache section |
InvertedSection Key [Node] | Inverted section |
Partial PName (Maybe Word) | Partial with indentation level ( |
Instances
Identifier for values to interpolate.
The representation is the following:
[]
— empty list means implicit iterators;[text]
— single key is a normal identifier;[text1, text2]
— multiple keys represent dotted names.
Instances
Data Key # | |||||
Defined in Text.Microstache.Type Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key # dataTypeOf :: Key -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Key) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) # gmapT :: (forall b. Data b => b -> b) -> Key -> Key # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r # gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key # | |||||
Monoid Key # | |||||
Semigroup Key # | |||||
Generic Key # | |||||
Defined in Text.Microstache.Type Associated Types
| |||||
Show Key # | |||||
NFData Key # | |||||
Defined in Text.Microstache.Type | |||||
Eq Key # | |||||
Ord Key # | |||||
type Rep Key # | |||||
Defined in Text.Microstache.Type |
Pretty-print a key, this is helpful, for example, if you want to display an error message.
Identifier for partials. Note that with the OverloadedStrings
extension you can use just string literals to create values of this type.
Instances
Data PName # | |||||
Defined in Text.Microstache.Type Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PName -> c PName # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PName # dataTypeOf :: PName -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PName) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PName) # gmapT :: (forall b. Data b => b -> b) -> PName -> PName # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PName -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PName -> r # gmapQ :: (forall d. Data d => d -> u) -> PName -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PName -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PName -> m PName # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PName -> m PName # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PName -> m PName # | |||||
IsString PName # | |||||
Defined in Text.Microstache.Type Methods fromString :: String -> PName # | |||||
Generic PName # | |||||
Defined in Text.Microstache.Type Associated Types
| |||||
Show PName # | |||||
NFData PName # | |||||
Defined in Text.Microstache.Type | |||||
Eq PName # | |||||
Ord PName # | |||||
type Rep PName # | |||||
Defined in Text.Microstache.Type |
data MustacheException #
Exception that is thrown when parsing of a template has failed or referenced values were not provided.
Constructors
MustacheParserException ParseError | Template parser has failed. This contains the parse error. |
MustacheRenderException PName Key | Deprecated: Not thrown anymore, will be removed in the next major version of microstache A referenced value was not provided. The exception provides info
about partial in which the issue happened |
Instances
Exception MustacheException # | |||||
Defined in Text.Microstache.Type Methods toException :: MustacheException -> SomeException # | |||||
Generic MustacheException # | |||||
Defined in Text.Microstache.Type Associated Types
Methods from :: MustacheException -> Rep MustacheException x # to :: Rep MustacheException x -> MustacheException # | |||||
Show MustacheException # | |||||
Defined in Text.Microstache.Type Methods showsPrec :: Int -> MustacheException -> ShowS # show :: MustacheException -> String # showList :: [MustacheException] -> ShowS # | |||||
Eq MustacheException # | |||||
Defined in Text.Microstache.Type Methods (==) :: MustacheException -> MustacheException -> Bool # (/=) :: MustacheException -> MustacheException -> Bool # | |||||
type Rep MustacheException # | |||||
Defined in Text.Microstache.Type type Rep MustacheException = D1 ('MetaData "MustacheException" "Text.Microstache.Type" "microstache-1.0.2.3-DwZkw7U9d9640vqKYO1sOg" 'False) (C1 ('MetaCons "MustacheParserException" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ParseError)) :+: C1 ('MetaCons "MustacheRenderException" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key))) |
displayMustacheException :: MustacheException -> String #
Since: 1.0.1
data MustacheWarning #
Since: 1.0.1
Constructors
MustacheVariableNotFound Key | The template contained a variable for which there was no data counterpart in the current context |
MustacheDirectlyRenderedValue Key | A complex value such as an Object or Array was directly rendered into the template |
Instances
Exception MustacheWarning # | |||||
Defined in Text.Microstache.Type Methods toException :: MustacheWarning -> SomeException # | |||||
Generic MustacheWarning # | |||||
Defined in Text.Microstache.Type Associated Types
Methods from :: MustacheWarning -> Rep MustacheWarning x # to :: Rep MustacheWarning x -> MustacheWarning # | |||||
Show MustacheWarning # | |||||
Defined in Text.Microstache.Type Methods showsPrec :: Int -> MustacheWarning -> ShowS # show :: MustacheWarning -> String # showList :: [MustacheWarning] -> ShowS # | |||||
Eq MustacheWarning # | |||||
Defined in Text.Microstache.Type Methods (==) :: MustacheWarning -> MustacheWarning -> Bool # (/=) :: MustacheWarning -> MustacheWarning -> Bool # | |||||
type Rep MustacheWarning # | |||||
Defined in Text.Microstache.Type type Rep MustacheWarning = D1 ('MetaData "MustacheWarning" "Text.Microstache.Type" "microstache-1.0.2.3-DwZkw7U9d9640vqKYO1sOg" 'False) (C1 ('MetaCons "MustacheVariableNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key)) :+: C1 ('MetaCons "MustacheDirectlyRenderedValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key))) |
displayMustacheWarning :: MustacheWarning -> String #
Since: 1.0.1