-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.Proposal
Milestone
Description
I need to use text/template to template a file over successive iterations. Initially not all data values will be present but on later iterations more and more data values will exist.
Currently, values not found in the data supplied to Template.Execute() are replaced depending on the active option (set via Template.Option()). By default the following template:
ID={{ .Id }}, Name={{ .Name }}
will be templated as:
ID=<no value>, Name=Bob
if executed with
data := map[string]interface{}{
"Name": "Bob",
}
But I need it to return:
ID={{ .Id }}, Name=Bob
Proposal
Adding a 'missingkey=ignore' option that would preserve the original tag in templated output if keys are missing from the data supplied when executing a template. I.e. the above template would return:
ID={{ .Id }}, Name=Bob
if executed with
data := map[string]interface{}{
"Name": "Bob",
}
This is a duplicate of #23488 but with a different use case.
sman591
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.Proposal