Documentation
¶
Index ¶
- type AutoescapeNode
- type BlockNode
- type DeprecatedNode
- type ForNode
- type Node
- type NodeList
- func (nl NodeList) BlockNames() []string
- func (nl NodeList) Dump() string
- func (nl NodeList) Extends() *SwExtendsNode
- func (nl NodeList) Find(predicate func(Node) bool) NodeList
- func (nl NodeList) FindBlock(name string) *BlockNode
- func (nl NodeList) RemoveWhitespace() NodeList
- func (nl NodeList) String() string
- func (nl NodeList) Traverse(visitor func(Node) Node) NodeList
- type ParentNode
- type PrintNode
- type SetNode
- type SwExtendsNode
- type TextNode
- type TypesNode
- type WhitespaceNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoescapeNode ¶
type AutoescapeNode struct {
Strategy string // e.g. "html"
Children NodeList // content within the autoescape block
}
AutoescapeNode represents an autoescape block in the template.
func (*AutoescapeNode) Dump ¶
func (a *AutoescapeNode) Dump() string
func (*AutoescapeNode) String ¶
func (a *AutoescapeNode) String(indent string) string
type BlockNode ¶
BlockNode represents a Twig block (with opening tag {% block <name> %} and ending tag {% endblock %}), and contains nested child nodes.
type DeprecatedNode ¶
type DeprecatedNode struct {
Message string
}
DeprecatedNode represents a deprecated tag in the template.
func (*DeprecatedNode) Dump ¶
func (d *DeprecatedNode) Dump() string
func (*DeprecatedNode) String ¶
func (d *DeprecatedNode) String(indent string) string
type Node ¶
type Node interface {
// String provides a debug representation with indentation.
String(indent string) string
// Dump outputs the node (and its children) back into source code.
Dump() string
}
Node represents an AST node.
type NodeList ¶
type NodeList []Node
func ParseTemplate ¶
ParseTemplate is the entry point that builds an AST for the template.
func (NodeList) BlockNames ¶
func (NodeList) Extends ¶
func (nl NodeList) Extends() *SwExtendsNode
func (NodeList) RemoveWhitespace ¶
type ParentNode ¶
type ParentNode struct{}
ParentNode represents the Twig expression {{ parent() }}.
func (*ParentNode) Dump ¶
func (p *ParentNode) Dump() string
func (*ParentNode) String ¶
func (p *ParentNode) String(indent string) string
type PrintNode ¶
type PrintNode struct {
Expression string
}
PrintNode represents an expression that prints a variable.
type SetNode ¶
type SetNode struct {
Variables []string // left-hand side variable(s)
Values []string // right-hand side expression(s) for inline assignment; empty when IsBlock is true
IsBlock bool // true when using block assignment
Children NodeList // block assignment content
}
SetNode represents a 'set' assignment in the template.
type SwExtendsNode ¶
SwExtendsNode represents the Twig tag for extending a template. It supports both simple and object-literal syntaxes.
func (*SwExtendsNode) Dump ¶
func (s *SwExtendsNode) Dump() string
func (*SwExtendsNode) String ¶
func (s *SwExtendsNode) String(indent string) string
type WhitespaceNode ¶
type WhitespaceNode struct {
Text string
}
WhitespaceNode holds a text fragment that consists solely of whitespace (spaces, tabs, newlines, etc).
func (*WhitespaceNode) Dump ¶
func (w *WhitespaceNode) Dump() string
func (*WhitespaceNode) String ¶
func (w *WhitespaceNode) String(indent string) string