Documentation ¶
Index ¶
- func NewContextStack(i interface{}) contextStack
- type AddExpr
- type BlockNode
- type BoolNode
- type CallNode
- type ConditionalNode
- type Context
- type Environment
- type ExtendsNode
- type FloatNode
- type ForNode
- type FromNode
- type IfBlockNode
- type Import
- type ImportNode
- type IncludeNode
- type IndexExpr
- type IntegerNode
- type ListNode
- type LookupNode
- type MacroNode
- type MapElem
- type MapExpr
- type MulExpr
- type Node
- type NodeType
- type Pos
- type PrintNode
- type SetNode
- type StringNode
- type Template
- type TextNode
- type Tree
- type UnaryNode
- type VarNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContextStack ¶
func NewContextStack(i interface{}) contextStack
Types ¶
type ConditionalNode ¶
A ConditionalNode is a node that has a guard and a body. If the guard evals as True, then the body is rendered. Otherwise, it's a Noop. If's and ElseIf's are modeled this way.
func (*ConditionalNode) Copy ¶
func (c *ConditionalNode) Copy() Node
func (*ConditionalNode) String ¶
func (c *ConditionalNode) String() string
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A context represents an environment passed in by a user to a template. Certain tags can create temporary contexts (for, macro, etc), which get created at eval time.
func NewContext ¶
Contexts can be structs or maps, or pointers to these types, but no other type.
type Environment ¶
type Environment struct { // The string marking the start of a block. Defaults to `{%`. BlockStartString string // The string marking the end of a block. Defaults to `%}`. BlockEndString string // The string marking the start of a var statement. Defaults to `{{`. VariableStartString string // The string marking the end of a var statement. Defaults to `}}`. VariableEndString string // The string marking the start of a comment. Defaults to `{#`. CommentStartString string // The string marking the end of a comment. Defaults to `#}`. CommentEndString string // If true, first newline after a block is removed. Default false. TrimBlocks bool // If true, leading whitespace is stripped from the start of a line to a block. Default false. LstripBlocks bool // If true, html auto-escaping is enabled by default for all var output. AutoEscape bool // Should the loader attempt to auto reload. AutoReload bool // Global variables to pass to every template. Shadowed by actual local contexts. Globals map[string]interface{} }
func NewEnvironment ¶
func NewEnvironment() *Environment
func (*Environment) ParseFragment ¶
func (e *Environment) ParseFragment(r io.Reader) (*Template, error)
func (*Environment) ParseString ¶
func (e *Environment) ParseString(source, name, filename string) (*Template, error)
type ExtendsNode ¶
type IfBlockNode ¶
IfBlockNode represents a full {% if %}... block. The if and elif bodies are modeled using the ConditionalNode, and are evaluated in order to determine which body to render. `Else` will be a ListNode, but can be nil if no such clause is present.
func (*IfBlockNode) Copy ¶
func (i *IfBlockNode) Copy() Node
func (*IfBlockNode) String ¶
func (i *IfBlockNode) String() string
type IncludeNode ¶
type IntegerNode ¶
func (*IntegerNode) Copy ¶
func (i *IntegerNode) Copy() Node
func (*IntegerNode) String ¶
func (i *IntegerNode) String() string
type LookupNode ¶
A LookupNode is a variable lookup.
func (*LookupNode) Copy ¶
func (l *LookupNode) Copy() Node
func (*LookupNode) String ¶
func (l *LookupNode) String() string
type StringNode ¶
func (*StringNode) Copy ¶
func (s *StringNode) Copy() Node
func (*StringNode) String ¶
func (s *StringNode) String() string
type Tree ¶
type Tree struct { Name string // name of the template represented by the tree. ParseName string // name of the top-level template during parsing, for error messages. Root *ListNode // top-level root of the tree. // contains filtered or unexported fields }
Tree is the representation of a single parsed template.
func (*Tree) ErrorContext ¶
ErrorContext returns a textual representation of the location of the node in the input text.