node.go (hugo-0.80.0) | : | node.go (hugo-0.81.0) | ||
---|---|---|---|---|
skipping to change at line 73 | skipping to change at line 73 | |||
NodeIf // An if action. | NodeIf // An if action. | |||
NodeList // A list of Nodes. | NodeList // A list of Nodes. | |||
NodeNil // An untyped nil constant. | NodeNil // An untyped nil constant. | |||
NodeNumber // A numerical constant. | NodeNumber // A numerical constant. | |||
NodePipe // A pipeline of commands. | NodePipe // A pipeline of commands. | |||
NodeRange // A range action. | NodeRange // A range action. | |||
NodeString // A string constant. | NodeString // A string constant. | |||
NodeTemplate // A template invocation action. | NodeTemplate // A template invocation action. | |||
NodeVariable // A $ variable. | NodeVariable // A $ variable. | |||
NodeWith // A with action. | NodeWith // A with action. | |||
NodeComment // A comment. | ||||
) | ) | |||
// Nodes. | // Nodes. | |||
// ListNode holds a sequence of nodes. | // ListNode holds a sequence of nodes. | |||
type ListNode struct { | type ListNode struct { | |||
NodeType | NodeType | |||
Pos | Pos | |||
tr *Tree | tr *Tree | |||
Nodes []Node // The element nodes in lexical order. | Nodes []Node // The element nodes in lexical order. | |||
skipping to change at line 152 | skipping to change at line 153 | |||
} | } | |||
func (t *TextNode) tree() *Tree { | func (t *TextNode) tree() *Tree { | |||
return t.tr | return t.tr | |||
} | } | |||
func (t *TextNode) Copy() Node { | func (t *TextNode) Copy() Node { | |||
return &TextNode{tr: t.tr, NodeType: NodeText, Pos: t.Pos, Text: append([ ]byte{}, t.Text...)} | return &TextNode{tr: t.tr, NodeType: NodeText, Pos: t.Pos, Text: append([ ]byte{}, t.Text...)} | |||
} | } | |||
// CommentNode holds a comment. | ||||
type CommentNode struct { | ||||
NodeType | ||||
Pos | ||||
tr *Tree | ||||
Text string // Comment text. | ||||
} | ||||
func (t *Tree) newComment(pos Pos, text string) *CommentNode { | ||||
return &CommentNode{tr: t, NodeType: NodeComment, Pos: pos, Text: text} | ||||
} | ||||
func (c *CommentNode) String() string { | ||||
var sb strings.Builder | ||||
c.writeTo(&sb) | ||||
return sb.String() | ||||
} | ||||
func (c *CommentNode) writeTo(sb *strings.Builder) { | ||||
sb.WriteString("{{") | ||||
sb.WriteString(c.Text) | ||||
sb.WriteString("}}") | ||||
} | ||||
func (c *CommentNode) tree() *Tree { | ||||
return c.tr | ||||
} | ||||
func (c *CommentNode) Copy() Node { | ||||
return &CommentNode{tr: c.tr, NodeType: NodeComment, Pos: c.Pos, Text: c. | ||||
Text} | ||||
} | ||||
// PipeNode holds a pipeline with optional declaration | // PipeNode holds a pipeline with optional declaration | |||
type PipeNode struct { | type PipeNode struct { | |||
NodeType | NodeType | |||
Pos | Pos | |||
tr *Tree | tr *Tree | |||
Line int // The line number in the input. Deprecated: Kep t for compatibility. | Line int // The line number in the input. Deprecated: Kep t for compatibility. | |||
IsAssign bool // The variables are being assigned, not declare d. | IsAssign bool // The variables are being assigned, not declare d. | |||
Decl []*VariableNode // Variables in lexical order. | Decl []*VariableNode // Variables in lexical order. | |||
Cmds []*CommandNode // The commands in lexical order. | Cmds []*CommandNode // The commands in lexical order. | |||
} | } | |||
skipping to change at line 352 | skipping to change at line 385 | |||
} | } | |||
func (i *IdentifierNode) tree() *Tree { | func (i *IdentifierNode) tree() *Tree { | |||
return i.tr | return i.tr | |||
} | } | |||
func (i *IdentifierNode) Copy() Node { | func (i *IdentifierNode) Copy() Node { | |||
return NewIdentifier(i.Ident).SetTree(i.tr).SetPos(i.Pos) | return NewIdentifier(i.Ident).SetTree(i.tr).SetPos(i.Pos) | |||
} | } | |||
// AssignNode holds a list of variable names, possibly with chained field | // VariableNode holds a list of variable names, possibly with chained field | |||
// accesses. The dollar sign is part of the (first) name. | // accesses. The dollar sign is part of the (first) name. | |||
type VariableNode struct { | type VariableNode struct { | |||
NodeType | NodeType | |||
Pos | Pos | |||
tr *Tree | tr *Tree | |||
Ident []string // Variable name and fields in lexical order. | Ident []string // Variable name and fields in lexical order. | |||
} | } | |||
func (t *Tree) newVariable(pos Pos, ident string) *VariableNode { | func (t *Tree) newVariable(pos Pos, ident string) *VariableNode { | |||
return &VariableNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: stri ngs.Split(ident, ".")} | return &VariableNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: stri ngs.Split(ident, ".")} | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 35 lines changed or added |