templateutil

package
v0.0.0-...-b75375f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2014 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package templateutil contains functions for parsing and walking go template trees.

Index

Constants

View Source
const (
	BeginTranslatableBlock = "begintrans"
	EndTranslatableBlock   = "endtrans"
)

Variables

This section is empty.

Functions

func DumpTree

func DumpTree(w io.Writer, tree *parse.Tree) error

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

func IsPseudoFunction(n parse.Node, fn string) bool

IsPseudoFunction returns true iff n is a *parse.ActionNode consisting solely of a fn call without any arguments.

func Parse

func Parse(name string, text string) (map[string]*parse.Tree, error)

Parse parses the given text as a set of template trees, adding placeholders for undefined functions and variables.

func ReplaceNode

func ReplaceNode(n parse.Node, p parse.Node, nn parse.Node) error

ReplaceNode replaces the n node in parent p with nn.

func ReplaceTranslatableBlocks

func ReplaceTranslatableBlocks(tr *parse.Tree, fn string) error

ReplaceTranslatableBlocks replaces begintrans/endtrans blocks with an equivalent action using the translation function named by fn.

func ReplaceVariableShorthands

func ReplaceVariableShorthands(text string, chr byte, name string) string

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.

func WalkNode

func WalkNode(node, parent parse.Node, f func(n, p parse.Node))

WalkNode visits all nodes starting from node, calling f with its parent. For the first call, the parent value is the one received as the second argument.

func WalkTree

func WalkTree(tree *parse.Tree, f func(n, p parse.Node))

WalkTree visits all the nodes in the tree, calling f for every node with its parent.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL