Documentation ¶
Overview ¶
Package parse builds parse trees for templates as defined by text/template and html/template. Clients should use those packages to construct templates rather than this one, which provides shared internal data structures not intended for general use.
Index ¶
Constants ¶
const ( ERROR token = iota EOF // End of File SPACE // White Space TEXT IDENT // names, variables AT_SIGN // @ COMMA // , L_PAREN // ( R_PAREN // ) L_DELIM // {{ R_DELIM // }} MODEL TABLE VIEW COUNTER )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CounterNode ¶
type CounterNode struct { NodeType Pos Text string // The text; may span newlines. // contains filtered or unexported fields }
CounterNode holds model
func (*CounterNode) Copy ¶
func (t *CounterNode) Copy() Node
func (*CounterNode) String ¶
func (t *CounterNode) String() string
type ListNode ¶
type ListNode struct { NodeType Pos Nodes []Node // The element nodes in lexical order. // contains filtered or unexported fields }
ListNode holds a sequence of nodes.
type ModelNode ¶
type ModelNode struct { NodeType Pos Text string // The text; may span newlines. // contains filtered or unexported fields }
ModelNode holds model
type Node ¶
type Node interface { Type() NodeType String() string // Copy does a deep copy of the Node and all its components. // To avoid type assertions, some XxxNodes also have specialized // CopyXxx methods that return *XxxNode. Copy() Node Position() Pos // byte position of start of node in full original input string // contains filtered or unexported methods }
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.
type Pos ¶
type Pos int
Pos represents a byte position in the original input text from which this template was parsed.
type TableNode ¶
type TableNode struct { NodeType Pos PartitionKeys []string ClusteringKeys []string // contains filtered or unexported fields }
TableNode holds table
type TextNode ¶
type TextNode struct { NodeType Pos Text string // The text; may span newlines. // contains filtered or unexported fields }
TextNode holds plain text.
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 Parse ¶
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.