]> Cypherpunks repositories - gostls13.git/commit
text/template, html/template: add block keyword and permit template redefinition
authorAndrew Gerrand <adg@golang.org>
Fri, 28 Aug 2015 05:31:51 +0000 (15:31 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 28 Sep 2015 06:01:30 +0000 (06:01 +0000)
commit12dfc3bee482f16263ce4673a0cce399127e2a0d
treeef8f60a50da69a5dfb3c8ab16082b385a59cfbec
parent09c6d13ac248eefd1d47e20457125ab5ac8b3246
text/template, html/template: add block keyword and permit template redefinition

This change adds a new "block" keyword that permits the definition
of templates inline inside existing templates, and loosens the
restriction on template redefinition. Templates may now be redefined,
but in the html/template package they may only be redefined before
the template is executed (and therefore escaped).

The intention is that such inline templates can be redefined by
subsequent template definitions, permitting a kind of template
"inheritance" or "overlay". (See the example for details.)

Fixes #3812

Change-Id: I733cb5332c1c201c235f759cc64333462e70dc27
Reviewed-on: https://go-review.googlesource.com/14005
Reviewed-by: Rob Pike <r@golang.org>
12 files changed:
src/html/template/clone_test.go
src/html/template/example_test.go
src/html/template/template.go
src/text/template/doc.go
src/text/template/example_test.go
src/text/template/exec_test.go
src/text/template/multi_test.go
src/text/template/parse/lex.go
src/text/template/parse/lex_test.go
src/text/template/parse/parse.go
src/text/template/parse/parse_test.go
src/text/template/template.go