Standard library / text/template/parse

text/template/parse.ListNode.CopyList()

CopyList copies the list and its child nodes, retaining a typed result. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (l *ListNode) CopyList() *ListNode

Return Value

*ListNode

CopyList copies the list and its child nodes, retaining a typed result.

Working Example

Example Snippetgo
package main
import (  "fmt"  "text/template/parse")
func tree(s string) *parse.Tree {  t := parse.New("demo")  t.Mode = parse.ParseComments | parse.SkipFuncCheck  _, e := t.Parse(s, "", "", map[string]*parse.Tree{})  if e != nil {    panic(e)  }  return t}func action(s string) *parse.ActionNode { return tree(s).Root.Nodes[0].(*parse.ActionNode) }
func main() {  t := tree("Hi {{.}}")  n := t.Root  c := n.CopyList()  fmt.Println(c != n && c.Nodes[0] != n.Nodes[0] && c.String() == n.String())}
Go Reference