Standard library / text/template/parse

text/template/parse.ParseComments

Retains comments as AST nodes when enabled on a new Tree. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
const ParseComments Mode

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")  t.Mode = parse.ParseComments  _, e := t.Parse("{{/* note */}}", "", "", map[string]*parse.Tree{})  check(e)  fmt.Println(t.Root.Nodes[0].Type() == parse.NodeComment)}
Go Reference