Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implements Ginger's Abstract Syntax Tree.
- type VarName = Text
- data Template = Template {}
- data Macro = Macro {}
- data Block = Block {}
- data Statement
- = MultiS [Statement]
- | ScopedS Statement
- | LiteralS Html
- | InterpolationS Expression
- | IfS Expression Statement Statement
- | SwitchS Expression [(Expression, Statement)] Statement
- | ForS (Maybe VarName) VarName Expression Statement
- | SetVarS VarName Expression
- | DefMacroS VarName Macro
- | BlockRefS VarName
- | PreprocessedIncludeS Template
- | NullS
- data Expression
- = StringLiteralE Text
- | NumberLiteralE Scientific
- | BoolLiteralE Bool
- | NullLiteralE
- | VarE VarName
- | ListE [Expression]
- | ObjectE [(Expression, Expression)]
- | MemberLookupE Expression Expression
- | CallE Expression [(Maybe Text, Expression)]
- | LambdaE [Text] Expression
- | TernaryE Expression Expression Expression
Documentation
Top-level data structure, representing a fully parsed template.
A macro definition ( {% macro %}
)
A block definition ( {% block %}
)
Ginger statements.
MultiS [Statement] | A sequence of multiple statements |
ScopedS Statement | Run wrapped statement in a local scope |
LiteralS Html | Literal output (anything outside of any tag) |
InterpolationS Expression | {{ expression }} |
IfS Expression Statement Statement | {% if expression %}statement{% else %}statement{% endif %} |
SwitchS Expression [(Expression, Statement)] Statement | {% switch expression %}{% case expression %}statement{% endcase %}...{% default %}statement{% enddefault %}{% endswitch %} |
ForS (Maybe VarName) VarName Expression Statement | {% for index, varname in expression %}statement{% endfor %} |
SetVarS VarName Expression | {% set varname = expr %} |
DefMacroS VarName Macro | {% macro varname %}statements{% endmacro %} |
BlockRefS VarName | |
PreprocessedIncludeS Template | {% include "template" %} |
NullS | The do-nothing statement (NOP) |
data Expression Source #
Expressions, building blocks for the expression minilanguage.
StringLiteralE Text | String literal expression: "foobar" |
NumberLiteralE Scientific | Numeric literal expression: 123.4 |
BoolLiteralE Bool | Boolean literal expression: true |
NullLiteralE | Literal null |
VarE VarName | Variable reference: foobar |
ListE [Expression] | List construct: [ expr, expr, expr ] |
ObjectE [(Expression, Expression)] | Object construct: { expr: expr, expr: expr, ... } |
MemberLookupE Expression Expression | foo[bar] (also dot access) |
CallE Expression [(Maybe Text, Expression)] | foo(bar=baz, quux) |
LambdaE [Text] Expression | (foo, bar) -> expr |
TernaryE Expression Expression Expression | expr ? expr : expr |