Documentation
¶
Index ¶
- func BinOp(token *tokens.Token) *nodes.BinOperator
- type ControlStructureGetter
- type ControlStructureParser
- type Parser
- func (p *Parser) Consume()
- func (p *Parser) Current(types ...tokens.Type) *tokens.Token
- func (p *Parser) CurrentName(names ...string) *tokens.Token
- func (p *Parser) End() bool
- func (p *Parser) Error(message string, token *tokens.Token) error
- func (p *Parser) Extend(identifier string) (*nodes.Template, error)
- func (p *Parser) Match(types ...tokens.Type) *tokens.Token
- func (p *Parser) MatchName(names ...string) *tokens.Token
- func (p *Parser) Next() *tokens.Token
- func (p *Parser) Parse() (*nodes.Template, error)
- func (p *Parser) ParseComment() (*nodes.Comment, error)
- func (p *Parser) ParseControlStructureBlock() (*nodes.ControlStructureBlock, error)
- func (p *Parser) ParseExpression() (nodes.Expression, error)
- func (p *Parser) ParseExpressionNode() (nodes.Node, error)
- func (p *Parser) ParseFilter() (*nodes.FilterCall, error)
- func (p *Parser) ParseFilterExpression(expr nodes.Expression) (nodes.Expression, error)
- func (p *Parser) ParseGetter(accessor *tokens.Token, from nodes.Expression) (nodes.Expression, error)
- func (p *Parser) ParseLogicalExpression() (nodes.Expression, error)
- func (p *Parser) ParseMath() (nodes.Expression, error)
- func (p *Parser) ParseMathPrioritary() (nodes.Expression, error)
- func (p *Parser) ParsePower() (nodes.Expression, error)
- func (p *Parser) ParseTest(expr nodes.Expression) (nodes.Expression, error)
- func (p *Parser) ParseVariable() (nodes.Expression, error)
- func (p *Parser) ParseVariableOrLiteral() (nodes.Expression, error)
- func (p *Parser) Peek(types ...tokens.Type) *tokens.Token
- func (p *Parser) Pop() *tokens.Token
- func (p *Parser) Stream() *tokens.Stream
- func (p *Parser) WrapUntil(names ...string) (*nodes.Wrapper, *Parser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ControlStructureGetter ¶
type ControlStructureGetter interface {
Get(name string) (ControlStructureParser, bool)
}
type ControlStructureParser ¶
type ControlStructureParser func(parser *Parser, args *Parser) (nodes.ControlStructure, error)
type Parser ¶
type Parser struct {
Config *config.Config
Template *nodes.Template
Loader loaders.Loader
// contains filtered or unexported fields
}
The parser provides you a comprehensive and easy tool to work with the template document and arguments provided by the user for your custom tag.
The parser works on a token list which will be provided by gonja. A token is a unit you can work with. Tokens are either of type identifier, string, number, keyword, HTML or symbol.
(See Token's documentation for more about tokens)
func NewParser ¶
func NewParser(identifier string, stream *tokens.Stream, cfg *config.Config, loader loaders.Loader, controlStructures ControlStructureGetter) *Parser
Creates a new parser to parse tokens. Used inside gonja to parse documents and to provide an easy-to-use parser for tag authors
func (*Parser) Current ¶
Current returns the current token without consuming it and only if it matches one of the given types
func (*Parser) Match ¶
Match returns the CURRENT token if the given type matches. Consumes this token on success.
func (*Parser) ParseControlStructureBlock ¶
func (p *Parser) ParseControlStructureBlock() (*nodes.ControlStructureBlock, error)
func (*Parser) ParseExpression ¶
func (p *Parser) ParseExpression() (nodes.Expression, error)
ParseExpression parses an expression with optional filters Nested expression should call this method
func (*Parser) ParseFilter ¶
func (p *Parser) ParseFilter() (*nodes.FilterCall, error)
func (*Parser) ParseFilterExpression ¶
func (p *Parser) ParseFilterExpression(expr nodes.Expression) (nodes.Expression, error)
ParseFilterExpression parses an optionnal filter chain for a node
func (*Parser) ParseGetter ¶
func (p *Parser) ParseGetter(accessor *tokens.Token, from nodes.Expression) (nodes.Expression, error)
func (*Parser) ParseLogicalExpression ¶
func (p *Parser) ParseLogicalExpression() (nodes.Expression, error)
func (*Parser) ParseMathPrioritary ¶
func (p *Parser) ParseMathPrioritary() (nodes.Expression, error)
func (*Parser) ParsePower ¶
func (p *Parser) ParsePower() (nodes.Expression, error)
func (*Parser) ParseTest ¶
func (p *Parser) ParseTest(expr nodes.Expression) (nodes.Expression, error)
func (*Parser) ParseVariable ¶
func (p *Parser) ParseVariable() (nodes.Expression, error)
func (*Parser) ParseVariableOrLiteral ¶
func (p *Parser) ParseVariableOrLiteral() (nodes.Expression, error)
IDENT | IDENT.(IDENT|NUMBER)...