Standard library / text/template/parse

text/template/parse.NodeTemplate

NodeType discriminator for named template invocation; parsing does not check that the target exists. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
const NodeTemplate NodeType

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("{{template \"header\" .}}")  n := t.Root.Nodes[0].(*parse.TemplateNode)  fmt.Println(n.Type() == parse.NodeTemplate)}
Go Reference