package parse

Import Path
	text/template/parse (on golang.org and go.dev)

Dependency Relation
	imports 7 packages, and imported by 2 packages

Involved Source Files
	    lex.go
	    node.go
	d-> parse.go

Exported Type Names

type ActionNode (struct) ActionNode holds an action (something bounded by delimiters). Control actions have their own nodes; ActionNode represents simple ones such as field evaluations and parenthesized pipelines. Line int NodeType NodeType Pipe *PipeNode Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type BoolNode (struct) BoolNode holds a boolean constant. NodeType NodeType Pos Pos True bool (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type BranchNode (struct) BranchNode is the common representation of if, range, and with. ElseList *ListNode Line int List *ListNode NodeType NodeType Pipe *PipeNode Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type ChainNode (struct) ChainNode holds a term followed by a chain of field accesses (identifier starting with '.'). The names may be chained ('.x.y'). The periods are dropped from each ident. Field []string Node Node NodeType NodeType Pos Pos (*T) Add(field string) (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type CommandNode (struct) CommandNode holds a command (a pipeline inside an evaluating action). Args []Node NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type DotNode (struct) DotNode holds the special identifier '.'. NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (*T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type FieldNode (struct) FieldNode holds a field (identifier starting with '.'). The names may be chained ('.x.y'). The period is dropped from each ident. Ident []string NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type IdentifierNode (struct) IdentifierNode holds an identifier. Ident string NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) SetPos(pos Pos) *IdentifierNode (*T) SetTree(t *Tree) *IdentifierNode (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer func NewIdentifier(ident string) *IdentifierNode func (*IdentifierNode).SetPos(pos Pos) *IdentifierNode func (*IdentifierNode).SetTree(t *Tree) *IdentifierNode
type IfNode (struct) IfNode represents an {{if}} action and its commands. BranchNode BranchNode BranchNode.ElseList *ListNode BranchNode.Line int BranchNode.List *ListNode BranchNode.NodeType NodeType BranchNode.Pipe *PipeNode BranchNode.Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type ListNode (struct) ListNode holds a sequence of nodes. NodeType NodeType Nodes []Node Pos Pos (*T) Copy() Node (*T) CopyList() *ListNode (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer func (*ListNode).CopyList() *ListNode
type NilNode (struct) NilNode holds the special identifier 'nil' representing an untyped nil constant. NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (*T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type Node (interface) A Node is an element in the parse tree. The interface is trivial. The interface contains an unexported method so that only types local to this package can satisfy it. (T) Copy() Node (T) Position() Pos (T) String() string (T) Type() NodeType *ActionNode *BoolNode *BranchNode *ChainNode *CommandNode *DotNode *FieldNode *IdentifierNode *IfNode *ListNode *NilNode *NumberNode *PipeNode *RangeNode *StringNode *TemplateNode *TextNode *VariableNode *WithNode T : expvar.Var T : fmt.Stringer func (*ActionNode).Copy() Node func (*BoolNode).Copy() Node func (*BranchNode).Copy() Node func (*ChainNode).Copy() Node func (*CommandNode).Copy() Node func (*DotNode).Copy() Node func (*FieldNode).Copy() Node func (*IdentifierNode).Copy() Node func (*IfNode).Copy() Node func (*ListNode).Copy() Node func (*NilNode).Copy() Node func Node.Copy() Node func (*NumberNode).Copy() Node func (*PipeNode).Copy() Node func (*RangeNode).Copy() Node func (*StringNode).Copy() Node func (*TemplateNode).Copy() Node func (*TextNode).Copy() Node func (*VariableNode).Copy() Node func (*WithNode).Copy() Node func IsEmptyTree(n Node) bool func (*Tree).ErrorContext(n Node) (location, context string)
type NodeType int NodeType identifies the type of a parse tree node. (T) Type() NodeType func (*DotNode).Type() NodeType func (*NilNode).Type() NodeType func Node.Type() NodeType func NodeType.Type() NodeType const NodeAction const NodeBool const NodeChain const NodeCommand const NodeDot const NodeField const NodeIdentifier const NodeIf const NodeList const NodeNil const NodeNumber const NodePipe const NodeRange const NodeString const NodeTemplate const NodeText const NodeVariable const NodeWith
type NumberNode (struct) NumberNode holds a number: signed or unsigned integer, float, or complex. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants. Complex128 complex128 Float64 float64 Int64 int64 IsComplex bool IsFloat bool IsInt bool IsUint bool NodeType NodeType Pos Pos Text string Uint64 uint64 (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type PipeNode (struct) PipeNode holds a pipeline with optional declaration Cmds []*CommandNode Decl []*VariableNode IsAssign bool Line int NodeType NodeType Pos Pos (*T) Copy() Node (*T) CopyPipe() *PipeNode (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer func (*PipeNode).CopyPipe() *PipeNode
type Pos int Pos represents a byte position in the original input text from which this template was parsed. (T) Position() Pos func Node.Position() Pos func Pos.Position() Pos func (*IdentifierNode).SetPos(pos Pos) *IdentifierNode
type RangeNode (struct) RangeNode represents a {{range}} action and its commands. BranchNode BranchNode BranchNode.ElseList *ListNode BranchNode.Line int BranchNode.List *ListNode BranchNode.NodeType NodeType BranchNode.Pipe *PipeNode BranchNode.Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type StringNode (struct) StringNode holds a string constant. The value has been "unquoted". NodeType NodeType Pos Pos Quoted string Text string (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type TemplateNode (struct) TemplateNode represents a {{template}} action. Line int Name string NodeType NodeType Pipe *PipeNode Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type TextNode (struct) TextNode holds plain text. NodeType NodeType Pos Pos Text []byte (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type Tree (struct) Tree is the representation of a single parsed template. Name string ParseName string Root *ListNode (*T) Copy() *Tree (*T) ErrorContext(n Node) (location, context string) (*T) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) func New(name string, funcs ...map[string]interface{}) *Tree func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (map[string]*Tree, error) func (*Tree).Copy() *Tree func (*Tree).Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) func (*IdentifierNode).SetTree(t *Tree) *IdentifierNode func (*Tree).Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) func text/template.(*Template).AddParseTree(name string, tree *Tree) (*template.Template, error) func html/template.(*Template).AddParseTree(name string, tree *Tree) (*template.Template, error)
type VariableNode (struct) VariableNode holds a list of variable names, possibly with chained field accesses. The dollar sign is part of the (first) name. Ident []string NodeType NodeType Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
type WithNode (struct) WithNode represents a {{with}} action and its commands. BranchNode BranchNode BranchNode.ElseList *ListNode BranchNode.Line int BranchNode.List *ListNode BranchNode.NodeType NodeType BranchNode.Pipe *PipeNode BranchNode.Pos Pos (*T) Copy() Node (T) Position() Pos (*T) String() string (T) Type() NodeType *T : Node *T : expvar.Var *T : fmt.Stringer
Exported Values
func IsEmptyTree(n Node) bool IsEmptyTree reports whether this tree (node) is empty of everything but space.
func New(name string, funcs ...map[string]interface{}) *Tree New allocates a new parse tree with the given name.
func NewIdentifier(ident string) *IdentifierNode NewIdentifier returns a new IdentifierNode with the given identifier name.
const NodeAction NodeType = 1 // A non-control action such as a field evaluation.
const NodeBool NodeType = 2 // A boolean constant.
const NodeChain NodeType = 3 // A sequence of field accesses.
const NodeCommand NodeType = 4 // An element of a pipeline.
const NodeDot NodeType = 5 // The cursor, dot.
const NodeField NodeType = 8 // A field or method name.
const NodeIdentifier NodeType = 9 // An identifier; always a function name.
const NodeIf NodeType = 10 // An if action.
const NodeList NodeType = 11 // A list of Nodes.
const NodeNil NodeType = 12 // An untyped nil constant.
const NodeNumber NodeType = 13 // A numerical constant.
const NodePipe NodeType = 14 // A pipeline of commands.
const NodeRange NodeType = 15 // A range action.
const NodeString NodeType = 16 // A string constant.
const NodeTemplate NodeType = 17 // A template invocation action.
const NodeText NodeType = 0 // Plain text.
const NodeVariable NodeType = 18 // A $ variable.
const NodeWith NodeType = 19 // A with action.
func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (map[string]*Tree, error) Parse returns a map from template name to parse.Tree, created by parsing the templates described in the argument string. The top-level template will be given the specified name. If an error is encountered, parsing stops and an empty map is returned with the error.