Standard library / text/template/parse
text/template/parse.Tree.Parse()
Populates a tree and the supplied tree set. Empty delimiters choose defaults; custom delimiters can be supplied. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Tree) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]any) (tree *Tree, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| text | string | Template source text, authored by a trusted developer. |
| leftDelim | string | Input to the operation as described above. |
| rightDelim | string | Input to the operation as described above. |
| treeSet | map[string]*Tree | Input to the operation as described above. |
| funcs | ...map[string]any | Input to the operation as described above. |
Return Value
(tree *Tree, err error)
Populates a tree and the supplied tree set.
Working Example
Example Snippetgo
package main
import ( "fmt" "text/template/parse")
func check(e error) { if e != nil { panic(e) }}
func main() { t := parse.New("demo") s := map[string]*parse.Tree{} _, e := t.Parse("[[.]]", "[[", "]]", s) check(e) fmt.Println(s["demo"] == t && t.Root.Nodes[0].Type() == parse.NodeAction)}