Standard library / text/template/parse

text/template/parse.Tree

Represents one named parsed template, with a root node list and parser mode. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type Tree struct {  Name      string  ParseName string  Root      *ListNode  Mode      Mode
}

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("Hello"); fmt.Println(t.Name == "demo" && t.Root.String() == "Hello") }
Go Reference