Skip to content

text/template: with on not existing key in map produce error with missingkey=error #13158

@zazab

Description

@zazab

It looks like a bug, that with action in templates produce error with missingkey=error.
Due the documentation with action is made for checking if pipeline is empty, and perfectly fits in logic, for example, if foo has key "bar", then print something. But with missingkey=error option it fails all template generation with error. (http://play.golang.org/p/kmmkkrHZYI)

I found a workaround for this case, using index function. It works as expected, and does not produce errors on not existent key. But it makes templates less readable, and, I think, simple addressing should have same behaviour.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions