| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.Ginger.AST
Description
Implements Ginger's Abstract Syntax Tree.
- type VarName = Text
- data Template = Template {}
- data Macro = Macro {}
- data Block = Block {}
- data Statement
- 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.
Constructors
| Template | |
Fields | |
A macro definition ( {% macro %} )
A block definition ( {% block %} )
Ginger statements.
Constructors
| 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 %} |
| 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.
Constructors
| 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 |
Instances