Reputation: 421
Anyone know ihow i can use an @size and a @eq together an @if condition?
{@size key=items /}
i want to say something to that effect:
{@if cond={@size key=items /} of {@eq key=items value= B } = 10} ...do this {:else} do that
which means look through my data, count how many items:B there are, if there are more than 1 do this or if it is 0 do that
Upvotes: 1
Views: 1713
Reputation: 484
The @provide helper will let you do that and many other things. See https://npmjs.org/package/dustmotes-provide.
{@provide}
{@if cond="numItems === 0"}
No items
{/if}
{:numItems}
{@size key=items /}
{/provide}
Your actual testing logic in the block after the @provide depends on what you want to test for but it would have the value numItems now available to directly reference. That value is computed in the {:numItems} block.
Upvotes: 2
Reputation: 657
Not possible at the moment, you would have to make your own custom helper for it. There is an effort to be able to add helper output to the context so you can reference it like any other dust variable:
https://github.com/linkedin/dustjs-helpers/pull/57
Upvotes: 0