I have an object with multiple properties viz propA, propB propC and propD. I want to write a condition with OR checking more than one parameter like below.
{@if cond="'{obj.propA}'.length > 0 || '{obj.propB}'.length > 0 || '{obj.propC}'.length> 0} ... {/if}
Now since @if is deprecated in dust, how do i write an equivalent of this with eq or select. Or is there a new helper i can utilize for such scenarios.
I'm assuming that the props you're testing are strings.
This example requires dustjs-helpers >= 1.6.
You can use the {@any}
and {@none}
helpers mentioned by @rragan like this:
{@select}
{@ne key=obj.propA value="" /}
{@ne key=obj.propB value="" /}
{@ne key=obj.propC value="" /}
{@any}At least one of the above tests was true. At least one prop is not an empty string.{/any}
{@none}None of the tests above passed. All the props are empty{/none}
{/select}