Documentation ¶
Overview ¶
Package templateutil contains functions for parsing and walking go template trees.
Index ¶
- Constants
- func DumpTree(w io.Writer, tree *parse.Tree) error
- func IsPseudoFunction(n parse.Node, fn string) bool
- func Parse(name string, text string) (map[string]*parse.Tree, error)
- func ReplaceNode(n parse.Node, p parse.Node, nn parse.Node) error
- func ReplaceTranslatableBlocks(tr *parse.Tree, fn string) error
- func ReplaceVariableShorthands(text string, chr byte, name string) string
- func TemplateNode(name string, pos parse.Pos) *parse.TemplateNode
- func WalkNode(node, parent parse.Node, f func(n, p parse.Node))
- func WalkTree(tree *parse.Tree, f func(n, p parse.Node))
Constants ¶
const ( BeginTranslatableBlock = "begintrans" EndTranslatableBlock = "endtrans" )
Variables ¶
This section is empty.
Functions ¶
func DumpTree ¶
DumpTree writes a *parse.Tree element by element to the given io.Writer. If w is nil, the result is printed to stdout.
func IsPseudoFunction ¶
IsPseudoFunction returns true iff n is a *parse.ActionNode consisting solely of a fn call without any arguments.
func Parse ¶
Parse parses the given text as a set of template trees, adding placeholders for undefined functions and variables.
func ReplaceNode ¶
ReplaceNode replaces the n node in parent p with nn.
func ReplaceTranslatableBlocks ¶
ReplaceTranslatableBlocks replaces begintrans/endtrans blocks with an equivalent action using the translation function named by fn.
func TemplateNode ¶
func TemplateNode(name string, pos parse.Pos) *parse.TemplateNode
TemplateNode returns a *parse.Template node invoking the given template passing . as the argument.
Types ¶
This section is empty.