diff options
Diffstat (limited to 'src/text/template/parse/node.go')
| -rw-r--r-- | src/text/template/parse/node.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/text/template/parse/node.go b/src/text/template/parse/node.go index 55ff46c17a..7e16349b31 100644 --- a/src/text/template/parse/node.go +++ b/src/text/template/parse/node.go @@ -69,6 +69,8 @@ const ( NodeTemplate // A template invocation action. NodeVariable // A $ variable. NodeWith // A with action. + NodeBreak // A break action. + NodeContinue // A continue action. ) // Nodes. @@ -796,6 +798,68 @@ func (r *RangeNode) Copy() Node { return r.tr.newRange(r.Pos, r.Line, r.Pipe.CopyPipe(), r.List.CopyList(), r.ElseList.CopyList()) } +// BreakNode represents a {{break}} action. +type BreakNode struct { + NodeType + Pos + tr *Tree +} + +func (t *Tree) newBreak(pos Pos) *BreakNode { + return &BreakNode{NodeType: NodeBreak, Pos: pos, tr: t} +} + +func (b *BreakNode) Type() NodeType { + return b.NodeType +} + +func (b *BreakNode) String() string { + return "{{break}}" +} + +func (b *BreakNode) Copy() Node { + return b.tr.newBreak(b.Pos) +} + +func (b *BreakNode) Position() Pos { + return b.Pos +} + +func (b *BreakNode) tree() *Tree { + return b.tr +} + +// ContinueNode represents a {{continue}} action. +type ContinueNode struct { + NodeType + Pos + tr *Tree +} + +func (t *Tree) newContinue(pos Pos) *ContinueNode { + return &ContinueNode{NodeType: NodeContinue, Pos: pos, tr: t} +} + +func (c *ContinueNode) Type() NodeType { + return c.NodeType +} + +func (c *ContinueNode) String() string { + return "{{continue}}" +} + +func (c *ContinueNode) Copy() Node { + return c.tr.newContinue(c.Pos) +} + +func (c *ContinueNode) Position() Pos { + return c.Pos +} + +func (c *ContinueNode) tree() *Tree { + return c.tr +} + // WithNode represents a {{with}} action and its commands. type WithNode struct { BranchNode |
