diff options
Diffstat (limited to 'src/text/template/parse/parse.go')
| -rw-r--r-- | src/text/template/parse/parse.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go index 5e6e512eb4..ff1358b001 100644 --- a/src/text/template/parse/parse.go +++ b/src/text/template/parse/parse.go @@ -38,7 +38,8 @@ type Tree struct { type Mode uint const ( - ParseComments Mode = 1 << iota // parse comments and add them to AST + ParseComments Mode = 1 << iota // parse comments and add them to AST + DeferFuncCheck // defer type checking functions until template is executed ) // Copy returns a copy of the Tree. Any parsing state is discarded. @@ -689,7 +690,8 @@ func (t *Tree) operand() Node { func (t *Tree) term() Node { switch token := t.nextNonSpace(); token.typ { case itemIdentifier: - if !t.hasFunction(token.val) { + checkFunc := t.Mode&DeferFuncCheck == 0 + if checkFunc && !t.hasFunction(token.val) { t.errorf("function %q not defined", token.val) } return NewIdentifier(token.val).SetTree(t).SetPos(token.pos) |
