stache-1.1.1: Mustache templates for Haskell

Copyright© 2016–2017 Stack Buliders
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.Mustache.Type

Description

Types used in the package. You don't usually need to import the module, because Text.Mustache re-exports everything you may need, import that module instead.

Synopsis

Documentation

data Template Source #

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 Templates (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

  • templateActual :: PName

    Name of currently “selected” template (top-level one).

  • templateCache :: Map PName [Node]

    Collection of all templates that are available for interpolation (as partials). The top-level one is also contained here and the “focus” can be switched easily by modifying templateActual.

Instances

Eq Template Source # 
Data Template Source # 

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 :: (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 #

Ord Template Source # 
Show Template Source # 
Generic Template Source # 

Associated Types

type Rep Template :: * -> * #

Methods

from :: Template -> Rep Template x #

to :: Rep Template x -> Template #

Semigroup Template Source # 
type Rep Template Source # 
type Rep Template = D1 (MetaData "Template" "Text.Mustache.Type" "stache-1.1.1-DXm1RrQQDJxI8daDuTBtU7" False) (C1 (MetaCons "Template" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "templateActual") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 PName)) (S1 (MetaSel (Just Symbol "templateCache") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map PName [Node])))))

data Node Source #

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 Pos)

Partial with indentation level (Nothing means it was inlined)

Instances

Eq Node Source # 

Methods

(==) :: Node -> Node -> Bool #

(/=) :: Node -> Node -> Bool #

Data Node Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Node -> c Node #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Node #

toConstr :: Node -> Constr #

dataTypeOf :: Node -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Node) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Node) #

gmapT :: (forall b. Data b => b -> b) -> Node -> Node #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r #

gmapQ :: (forall d. Data d => d -> u) -> Node -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Node -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Node -> m Node #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node #

Ord Node Source # 

Methods

compare :: Node -> Node -> Ordering #

(<) :: Node -> Node -> Bool #

(<=) :: Node -> Node -> Bool #

(>) :: Node -> Node -> Bool #

(>=) :: Node -> Node -> Bool #

max :: Node -> Node -> Node #

min :: Node -> Node -> Node #

Show Node Source # 

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

Generic Node Source # 

Associated Types

type Rep Node :: * -> * #

Methods

from :: Node -> Rep Node x #

to :: Rep Node x -> Node #

type Rep Node Source # 

newtype Key Source #

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.

Constructors

Key 

Fields

Instances

Eq Key Source # 

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Data Key Source # 

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 #

toConstr :: Key -> Constr #

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 :: (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 #

Ord Key Source # 

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Show Key Source # 

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Generic Key Source # 

Associated Types

type Rep Key :: * -> * #

Methods

from :: Key -> Rep Key x #

to :: Rep Key x -> Key #

Semigroup Key Source # 

Methods

(<>) :: Key -> Key -> Key #

sconcat :: NonEmpty Key -> Key #

stimes :: Integral b => b -> Key -> Key #

Monoid Key Source # 

Methods

mempty :: Key #

mappend :: Key -> Key -> Key #

mconcat :: [Key] -> Key #

NFData Key Source # 

Methods

rnf :: Key -> () #

type Rep Key Source # 
type Rep Key = D1 (MetaData "Key" "Text.Mustache.Type" "stache-1.1.1-DXm1RrQQDJxI8daDuTBtU7" True) (C1 (MetaCons "Key" PrefixI True) (S1 (MetaSel (Just Symbol "unKey") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text])))

showKey :: Key -> Text Source #

Pretty-print a key, this is helpful, for example, if you want to display an error message.

Since: 0.2.0

newtype PName Source #

Identifier for partials. Note that with the OverloadedStrings extension you can use just string literals to create values of this type.

Constructors

PName 

Fields

Instances

Eq PName Source # 

Methods

(==) :: PName -> PName -> Bool #

(/=) :: PName -> PName -> Bool #

Data PName Source # 

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 #

toConstr :: PName -> Constr #

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 :: (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 #

Ord PName Source # 

Methods

compare :: PName -> PName -> Ordering #

(<) :: PName -> PName -> Bool #

(<=) :: PName -> PName -> Bool #

(>) :: PName -> PName -> Bool #

(>=) :: PName -> PName -> Bool #

max :: PName -> PName -> PName #

min :: PName -> PName -> PName #

Show PName Source # 

Methods

showsPrec :: Int -> PName -> ShowS #

show :: PName -> String #

showList :: [PName] -> ShowS #

IsString PName Source # 

Methods

fromString :: String -> PName #

Generic PName Source # 

Associated Types

type Rep PName :: * -> * #

Methods

from :: PName -> Rep PName x #

to :: Rep PName x -> PName #

NFData PName Source # 

Methods

rnf :: PName -> () #

type Rep PName Source # 
type Rep PName = D1 (MetaData "PName" "Text.Mustache.Type" "stache-1.1.1-DXm1RrQQDJxI8daDuTBtU7" True) (C1 (MetaCons "PName" PrefixI True) (S1 (MetaSel (Just Symbol "unPName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

data MustacheException Source #

Exception that is thrown when parsing of a template fails or referenced values are not provided.

Constructors

MustacheParserException Text (ParseError Char Void)

Template parser has failed. This contains the parse error.

Before version 0.2.0 it was called MustacheException.

The Text field was added in version 1.0.0.

data MustacheWarning Source #

Warning that may be generated during rendering of a Template.

Since: 1.1.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.