ginger-0.10.5.2: An implementation of the Jinja2 template language in Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Ginger.AST

Description

Implements Ginger's Abstract Syntax Tree.

Synopsis

Documentation

type VarName = Text Source #

A context variable name.

data Template a Source #

Top-level data structure, representing a fully parsed template.

Instances

Instances details
Functor Template Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> Template a -> Template b #

(<$) :: a -> Template b -> Template a #

Annotated Template Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Template p -> p Source #

Show a => Show (Template a) Source # 
Instance details

Defined in Text.Ginger.AST

Methods

showsPrec :: Int -> Template a -> ShowS #

show :: Template a -> String #

showList :: [Template a] -> ShowS #

Optimizable (Template a) Source # 
Instance details

Defined in Text.Ginger.Optimizer

Methods

optimize :: Template a -> Template a Source #

data Macro a Source #

A macro definition ( {% macro %} )

Constructors

Macro 

Instances

Instances details
Functor Macro Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> Macro a -> Macro b #

(<$) :: a -> Macro b -> Macro a #

Annotated Macro Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Macro p -> p Source #

Show a => Show (Macro a) Source # 
Instance details

Defined in Text.Ginger.AST

Methods

showsPrec :: Int -> Macro a -> ShowS #

show :: Macro a -> String #

showList :: [Macro a] -> ShowS #

Optimizable (Macro a) Source # 
Instance details

Defined in Text.Ginger.Optimizer

Methods

optimize :: Macro a -> Macro a Source #

data Block a Source #

A block definition ( {% block %} )

Constructors

Block 

Fields

Instances

Instances details
Functor Block Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> Block a -> Block b #

(<$) :: a -> Block b -> Block a #

Annotated Block Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Block p -> p Source #

Show a => Show (Block a) Source # 
Instance details

Defined in Text.Ginger.AST

Methods

showsPrec :: Int -> Block a -> ShowS #

show :: Block a -> String #

showList :: [Block a] -> ShowS #

Optimizable (Block a) Source # 
Instance details

Defined in Text.Ginger.Optimizer

Methods

optimize :: Block a -> Block a Source #

data Statement a Source #

Ginger statements.

Constructors

MultiS a [Statement a]

A sequence of multiple statements

ScopedS a (Statement a)

Run wrapped statement in a local scope

IndentS a (Expression a) (Statement a)

Establish an indented context around the wrapped statement

LiteralS a Html

Literal output (anything outside of any tag)

InterpolationS a (Expression a)

{{ expression }}

ExpressionS a (Expression a)

Evaluate expression

IfS a (Expression a) (Statement a) (Statement a)

{% if expression %}statement{% else %}statement{% endif %}

SwitchS a (Expression a) [(Expression a, Statement a)] (Statement a)

{% switch expression %}{% case expression %}statement{% endcase %}...{% default %}statement{% enddefault %}{% endswitch %}

ForS a (Maybe VarName) VarName (Expression a) (Statement a)

{% for index, varname in expression %}statement{% endfor %}

SetVarS a VarName (Expression a)

{% set varname = expr %}

DefMacroS a VarName (Macro a)

{% macro varname %}statements{% endmacro %}

BlockRefS a VarName 
PreprocessedIncludeS a (Template a)

{% include "template" %}

NullS a

The do-nothing statement (NOP)

TryCatchS a (Statement a) [CatchBlock a] (Statement a)

Try catch finally

Instances

Instances details
Functor Statement Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> Statement a -> Statement b #

(<$) :: a -> Statement b -> Statement a #

Annotated Statement Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Statement p -> p Source #

Show a => Show (Statement a) Source # 
Instance details

Defined in Text.Ginger.AST

Optimizable (Statement a) Source # 
Instance details

Defined in Text.Ginger.Optimizer

data CatchBlock a Source #

A catch block

Instances

Instances details
Functor CatchBlock Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> CatchBlock a -> CatchBlock b #

(<$) :: a -> CatchBlock b -> CatchBlock a #

Show a => Show (CatchBlock a) Source # 
Instance details

Defined in Text.Ginger.AST

data Expression a Source #

Expressions, building blocks for the expression minilanguage.

Constructors

StringLiteralE a Text

String literal expression: "foobar"

NumberLiteralE a Scientific

Numeric literal expression: 123.4

BoolLiteralE a Bool

Boolean literal expression: true

NullLiteralE a

Literal null

VarE a VarName

Variable reference: foobar

ListE a [Expression a]

List construct: [ expr, expr, expr ]

ObjectE a [(Expression a, Expression a)]

Object construct: { expr: expr, expr: expr, ... }

MemberLookupE a (Expression a) (Expression a)

foo[bar] (also dot access)

CallE a (Expression a) [(Maybe Text, Expression a)]

foo(bar=baz, quux)

LambdaE a [Text] (Expression a)

(foo, bar) -> expr

TernaryE a (Expression a) (Expression a) (Expression a)

expr ? expr : expr

DoE a (Statement a)

do { statement; }

Instances

Instances details
Functor Expression Source # 
Instance details

Defined in Text.Ginger.AST

Methods

fmap :: (a -> b) -> Expression a -> Expression b #

(<$) :: a -> Expression b -> Expression a #

Annotated Expression Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Expression p -> p Source #

Show a => Show (Expression a) Source # 
Instance details

Defined in Text.Ginger.AST

Optimizable (Expression a) Source # 
Instance details

Defined in Text.Ginger.Optimizer

class Annotated f where Source #

Methods

annotation :: f p -> p Source #

Instances

Instances details
Annotated Block Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Block p -> p Source #

Annotated Expression Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Expression p -> p Source #

Annotated Macro Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Macro p -> p Source #

Annotated Statement Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Statement p -> p Source #

Annotated Template Source # 
Instance details

Defined in Text.Ginger.AST

Methods

annotation :: Template p -> p Source #