1
0
mirror of https://github.com/golang/go synced 2024-10-02 20:31:21 -06:00
go/src/html
Rob Pike 4e5ac45ec5 text/template: provide a mechanism for options
Add one option, which is the motivating example, a way to control
what happens when a map is indexed with a key that is not in the map.
Rather than do something specific for that case, we provide a simple
general option mechanism to avoid adding API if something else
comes up. This general approach also makes it easy for html/template
to track (and adapt, should that become important).

New method: Option(option string...). The option strings are key=value
pairs or just simple strings (no =).

New option:

 missingkey: Control the behavior during execution if a map is
 indexed with a key that is not present in the map.
	"missingkey=default" or "missingkey=invalid"
		The default behavior: Do nothing and continue execution.
		If printed, the result of the index operation is the string
		"<no value>".
	"missingkey=zero"
		The operation returns the zero value for the map type's element.
	"missingkey=error"
		Execution stops immediately with an error.

Fixes #6288.

Change-Id: Id811e2b99dc05aff324d517faac113ef3c25293a
Reviewed-on: https://go-review.googlesource.com/8462
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-03 23:40:59 +00:00
..
template text/template: provide a mechanism for options 2015-04-03 23:40:59 +00:00
entity_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
entity.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
escape_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
escape.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00