Copyright | (c) Justus Adam, 2015 |
---|---|
License | LGPL-3 |
Maintainer | development@justusadam.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- type AST = [Node Text]
- data Template = Template {}
- data Node α
- data DataIdentifier
- data Value
- object :: [Pair] -> Value
- (~>) :: ToMustache ω => Text -> ω -> Pair
- (↝) :: ToMustache ω => Text -> ω -> Pair
- (~=) :: ToJSON ι => Text -> ι -> Pair
- (⥱) :: ToJSON ι => Text -> ι -> Pair
- (~~>) :: (Conversion ζ Text, ToMustache ω) => ζ -> ω -> Pair
- (~↝) :: (Conversion ζ Text, ToMustache ω) => ζ -> ω -> Pair
- (~~=) :: (Conversion ζ Text, ToJSON ι) => ζ -> ι -> Pair
- (~⥱) :: (Conversion ζ Text, ToJSON ι) => ζ -> ι -> Pair
- class ToMustache ω where
- toMustache :: ω -> Value
- toTextBlock :: Conversion ζ Text => ζ -> Value
- mFromJSON :: ToJSON ι => ι -> Value
- type Array = Vector Value
- type Object = HashMap Text Value
- data Context α = Context [α] α
Types for the Parser / Template
A compiled Template with metadata.
Basic values composing the AST
TextBlock α | |
Section DataIdentifier AST | |
InvertedSection DataIdentifier AST | |
Variable Bool DataIdentifier | |
Partial (Maybe α) FilePath |
Eq α => Eq (Node α) Source | |
Show α => Show (Node α) Source | |
ToMustache (Context Value -> AST -> String) Source | |
ToMustache (Context Value -> AST -> Text) Source | |
ToMustache (Context Value -> AST -> AST) Source | |
ToMustache (AST -> String) Source | |
ToMustache (AST -> Text) Source | |
ToMustache (AST -> AST) Source |
data DataIdentifier Source
Types for the Substitution / Data
Internal value AST
Converting
object :: [Pair] -> Value Source
Convenience function for creating Object values.
This function is supposed to be used in conjuction with the ~>
and ~=
operators.
Examples
data Address = Address { ... } instance Address ToJSON where ... data Person = Person { name :: String, address :: Address } instance ToMustache Person where toMustache (Person { name, address }) = object [ "name" ~> name , "address" ~= address ]
Here we can see that we can use the ~>
operator for values that have themselves
a ToMustache
instance, or alternatively if they lack such an instance but provide
an instance for the ToJSON
typeclass we can use the ~=
operator.
(~>) :: ToMustache ω => Text -> ω -> Pair Source
Map keys to values that provide a ToMustache
instance
Recommended in conjunction with the OverloadedStrings
extension.
(↝) :: ToMustache ω => Text -> ω -> Pair Source
Unicode version of ~>
(~=) :: ToJSON ι => Text -> ι -> Pair Source
Map keys to values that provide a ToJSON
instance
Recommended in conjunction with the OverloadedStrings
extension.
(~~>) :: (Conversion ζ Text, ToMustache ω) => ζ -> ω -> Pair Source
Conceptually similar to ~>
but uses arbitrary String-likes as keys.
(~↝) :: (Conversion ζ Text, ToMustache ω) => ζ -> ω -> Pair Source
Unicde version of ~~>
(~~=) :: (Conversion ζ Text, ToJSON ι) => ζ -> ι -> Pair Source
Conceptually similar to ~=
but uses arbitrary String-likes as keys.
class ToMustache ω where Source
Conversion class
toMustache :: ω -> Value Source
toTextBlock :: Conversion ζ Text => ζ -> Value Source
Converts arbitrary String-likes to Values
mFromJSON :: ToJSON ι => ι -> Value Source
Converts a value that can be represented as JSON to a Value.