diff options
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/html/template/template.go')
| -rw-r--r-- | llgo/third_party/gofrontend/libgo/go/html/template/template.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/html/template/template.go b/llgo/third_party/gofrontend/libgo/go/html/template/template.go index ce6170105cc..bb9140a4daf 100644 --- a/llgo/third_party/gofrontend/libgo/go/html/template/template.go +++ b/llgo/third_party/gofrontend/libgo/go/html/template/template.go @@ -51,11 +51,37 @@ 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() defer t.nameSpace.mu.Unlock() if t.escapeErr == nil { + if t.Tree == nil { + return fmt.Errorf("template: %q is an incomplete or empty template%s", t.Name(), t.text.DefinedTemplates()) + } if err := escapeTemplate(t, t.text.Root, t.Name()); err != nil { return err } |

