const ( VarTypeInt = iota VarTypeIdent )
func Inspect(node Node, f func(Node) bool)
Inspect traverses an AST in depth-first order: It starts by calling f(node); node must not be nil. If f returns true, Inspect invokes f recursively for each of the non-nil children of node, followed by a call of f(nil).
func Walk(v Visitor, node Node) error
type BinOperator struct { Token *tokens.Token }
func (op BinOperator) Position() *tokens.Token
func (op BinOperator) String() string
type BinaryExpression struct { Left Expression Right Expression Operator *BinOperator }
func (b *BinaryExpression) Position() *tokens.Token
func (expr *BinaryExpression) String() string
type BlockSet map[string]*Wrapper
func (bs BlockSet) Exists(name string) bool
Exists returns true if the given block is already registered
func (bs *BlockSet) Register(name string, w *Wrapper) error
Register registers a new block. If there's already a filter with the same name, Register will panic. You usually want to call this function in the filter's init() function: http://golang.org/doc/effective_go.html#init
See http://www.florian-schlachter.de/post/gonja/ for more about writing filters and tags.
func (bs *BlockSet) Replace(name string, w *Wrapper) error
Replace replaces an already registered filter with a new implementation. Use this function with caution since it allobs you to change existing filter behaviour.
type Bool struct { Location *tokens.Token Val bool }
func (b *Bool) Position() *tokens.Token
func (b *Bool) String() string
type Call struct { Location *tokens.Token Func Node Args []Expression Kwargs map[string]Expression }
func (c *Call) Position() *tokens.Token
func (c *Call) String() string
A Comment node represents a single {# #} comment.
type Comment struct { Start *tokens.Token // Opening token Text string // Comment text End *tokens.Token // Closing token Trim *Trim }
func (c *Comment) Position() *tokens.Token
func (c *Comment) String() string
func (c *Comment) End() token.Pos { return token.Pos(int(c.Slash) + len(c.Text)) }
type Data struct { Data *tokens.Token // data token }
func (d *Data) Position() *tokens.Token
func (c *Data) String() string
func (c *Comment) End() token.Pos { return token.Pos(int(c.Slash) + len(c.Text)) }
type Dict struct { Token *tokens.Token Pairs []*Pair }
func (d *Dict) Position() *tokens.Token
func (d *Dict) String() string
Expression represents an evaluable expression part
type Expression interface { Node }
type FilterCall struct { Token *tokens.Token Name string Args []Expression Kwargs map[string]Expression }
type FilteredExpression struct { Expression Expression Filters []*FilterCall }
func (expr *FilteredExpression) Position() *tokens.Token
func (expr *FilteredExpression) String() string
type Float struct { Location *tokens.Token Val float64 }
func (f *Float) Position() *tokens.Token
func (f *Float) String() string
type Getattr struct { Location *tokens.Token Node Node Attr string Index int }
func (g *Getattr) Position() *tokens.Token
func (g *Getattr) String() string
type Getitem struct { Location *tokens.Token Node Node Arg string Index int }
func (g *Getitem) Position() *tokens.Token
func (g *Getitem) String() string
type Inspector func(Node) bool
func (f Inspector) Visit(node Node) (Visitor, error)
type Integer struct { Location *tokens.Token Val int }
func (i *Integer) Position() *tokens.Token
func (i *Integer) String() string
type List struct { Location *tokens.Token Val []Expression }
func (l *List) Position() *tokens.Token
func (l *List) String() string
type Macro struct { Location *tokens.Token Name string Args []string Kwargs []*Pair Wrapper *Wrapper }
func (m *Macro) Position() *tokens.Token
func (m *Macro) String() string
type Name struct { Name *tokens.Token }
func (n *Name) Position() *tokens.Token
func (n *Name) String() string
type Negation struct { Term Expression Operator *tokens.Token }
func (n *Negation) Position() *tokens.Token
func (n *Negation) String() string
All node types implement the Node interface.
type Node interface { fmt.Stringer Position() *tokens.Token }
Ouput represents a printable expression node {{ }}
type Output struct { Start *tokens.Token Expression Expression End *tokens.Token Trim *Trim }
func (o *Output) Position() *tokens.Token
func (o *Output) String() string
type Pair struct { Key Expression Value Expression }
func (p *Pair) Position() *tokens.Token
func (p *Pair) String() string
Statement represents a statement block "{% %}"
type Statement interface { Node }
type StatementBlock struct { Location *tokens.Token Name string Stmt Statement Trim *Trim LStrip bool }
func (s StatementBlock) Position() *tokens.Token
func (s StatementBlock) String() string
type String struct { Location *tokens.Token Val string }
func (s *String) Position() *tokens.Token
func (s *String) String() string
Template is the root node of any template
type Template struct { Name string Nodes []Node Blocks BlockSet Macros map[string]*Macro Parent *Template }
func (tpl *Template) GetBlocks(name string) []*Wrapper
func (t *Template) Position() *tokens.Token
func (t *Template) String() string
type TestCall struct { Token *tokens.Token Name string Args []Expression Kwargs map[string]Expression }
func (tc *TestCall) String() string
type TestExpression struct { Expression Expression Test *TestCall }
func (expr *TestExpression) Position() *tokens.Token
func (expr *TestExpression) String() string
type Trim struct { Left bool Right bool }
type Tuple struct { Location *tokens.Token Val []Expression }
func (t *Tuple) Position() *tokens.Token
func (t *Tuple) String() string
type UnaryExpression struct { Negative bool Term Expression Operator *tokens.Token }
func (u *UnaryExpression) Position() *tokens.Token
func (u *UnaryExpression) String() string
type Variable struct { Location *tokens.Token Parts []*VariablePart }
func (v *Variable) Position() *tokens.Token
func (v *Variable) String() string
type VariablePart struct { Type int S string I int IsFunctionCall bool // callingArgs []functionCallArgument // needed for a function call, represents all argument nodes (Node supports nested function calls) Args []Expression Kwargs map[string]Expression }
func (vp *VariablePart) String() string
type Visitor interface { Visit(node Node) (Visitor, error) }
type Wrapper struct { Location *tokens.Token Nodes []Node EndTag string Trim *Trim LStrip bool }
func (w Wrapper) Position() *tokens.Token
func (w Wrapper) String() string