Skip to content

text/template: (and html/template) execution option for given errors for missing map keys #6288

@gopherbot

Description

@gopherbot

by bjruth:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

http://play.golang.org/p/zVTrueV2dd

Note the '<no value>' value for lastName.

What is the expected output?

I expect fields used in the template that are missing in the map should return an error
(missing key) rather than render '<no value>'

Please provide any additional information below.

Discussion on golang-nuts:
https://groups.google.com/forum/#!topic/golang-nuts/VPhthY-ocsg

An ideal solution would be a Template.ExecuteStrict method that returns an error rather
than replacing missing keys/fields with '<no value>' in the output (as it does
now). This ensures nothing breaks with programs using Template.Execute in Go 1.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions