conditional based on parameter undefined/defined fail when value is parameter
If I reference a value that is undefined in the current context, I get an unwelcome warning: e.g., with parent context
{
data: [{
item : "exampleA",
blah : "This example"
},{
item : "exampleB"
}]
}
And a template "boo.dust"
{blah} is good
Invoked as a section:
{#data}
{> boo/}
{/data}
The second entry, exampleB, gives a warning:
[DUST:INFO] Cannot find reference '{blah}' in template 'boo'
What I need to do is conditionally render a partial like this:
{@exists key='blah'}
{blah} is good
{/exists}
I wrote a helper that works fine in the above example, but it fails if instead of passing the key in the context, I send it as a parameter, e.g., FAIL
{
data: [{
item : "exampleA",
},{
item : "exampleB"
}]
}
And a template "boo.dust"
{blah} is good
Invoked as a section:
{#data}
{> boo blah="THIS EXAMPLE"/}
{/data}
I tried using {?exists/} as described in http://www.dustjs.com/docs/syntax/ but there isn't any actual example code, so it's not clear how to do it and I couldn't get it working.
Any pointers welcome.
Just opened an issue, so thought I would help with a question as well.
Using your example above, your partial should look like this:
{?blah}
{blah} is good
{/blah}
The full output of the template would look like the following:
{#data}
{?blah}
{blah} is good
{/blah}
{/data}