mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
tpl/internal: Synch Go templates fork with Go 1.16dev
This commit is contained in:
@@ -70,6 +70,7 @@ const (
|
||||
NodeTemplate // A template invocation action.
|
||||
NodeVariable // A $ variable.
|
||||
NodeWith // A with action.
|
||||
NodeComment // A comment.
|
||||
)
|
||||
|
||||
// Nodes.
|
||||
@@ -149,6 +150,38 @@ func (t *TextNode) Copy() Node {
|
||||
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
|
||||
type PipeNode struct {
|
||||
NodeType
|
||||
@@ -349,7 +382,7 @@ func (i *IdentifierNode) Copy() Node {
|
||||
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.
|
||||
type VariableNode struct {
|
||||
NodeType
|
||||
|
Reference in New Issue
Block a user