diff options
Diffstat (limited to 'src/html')
| -rw-r--r-- | src/html/template/template.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/html/template/template.go b/src/html/template/template.go index 64c0041c9c..bb9140a4da 100644 --- a/src/html/template/template.go +++ b/src/html/template/template.go @@ -51,6 +51,29 @@ func (t *Template) Templates() []*Template { return m } +// Option sets options for the template. Options are described by +// strings, either a simple string or "key=value". There can be at +// most one equals sign in an option string. If the option string +// is unrecognized or otherwise invalid, Option panics. +// +// Known options: +// +// 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. +// +func (t *Template) Option(opt ...string) *Template { + t.text.Option(opt...) + return t +} + // escape escapes all associated templates. func (t *Template) escape() error { t.nameSpace.mu.Lock() |
