]> Cypherpunks repositories - gostls13.git/commit
exp/template/html: allow commenting out of actions
authorMike Samuel <mikesamuel@gmail.com>
Tue, 20 Sep 2011 02:52:31 +0000 (19:52 -0700)
committerMike Samuel <mikesamuel@gmail.com>
Tue, 20 Sep 2011 02:52:31 +0000 (19:52 -0700)
commit8bc5ef6cd7627eb6fe41e4f60cb33221d681927d
tree322f01d5d7b5543bf8ddfe071014a30ca8ec39ee
parent533b372280a2124f39a1093e7211f5b677b619d9
exp/template/html: allow commenting out of actions

Instead of erroring on actions inside comments, use existing escaping
pipeline to quash the output of actions inside comments.

If a template maintainer uses a comment to disable template code:

  {{if .}}Hello, {{.}}!{{end}}

->

  <!--{{if true}}Hello, {{.}}!{{end}}-->

will result in

  <!--Hello, !-->

regardless of the value of {{.}}.

In a later CL, comment elision will result in the entire commented-out
section being dropped from the template output.

Any side-effects in pipelines, such as panics, will still be realized.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5078041
src/pkg/exp/template/html/error.go
src/pkg/exp/template/html/escape.go
src/pkg/exp/template/html/escape_test.go
src/pkg/exp/template/html/html.go