Skip to content

Is it possible to return a custom string if the key is missing from context? #318

@alindsay55661

Description

@alindsay55661

Rather than having nothing come back, I would like to generate the key wrapped in braces. For example this context:

{ foo: 'foo' }

And this template:

<div>{{foo}}</div>
<div>{{bar}}</div>

Should render this output:

<div>foo</div>
<div>{{bar}}</div>

// or this...
<div>foo</div>
<div>[[bar]]</div>

// or this...
<div>foo</div>
<div>{{missing key - bar}}</div>

instead of this:

<div>foo</div>
<div></div>

The idea is to have a custom template that can be returned for keys that are missing from the given context rather than an empty string. This really helps me identify visually where certain keys in my context are missing, and which keys those are. Is this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions