Can the {@size} helper be used inside the {@math} helper in dust?
1 answer
Dust does not allow using a helper as the value of the passed parameter.
In general, once you start nesting helpers, you should ask if you are nesting too much logic in your templates and not in the context - this is what Dust is trying to enforce with relatively strong constraints.
You can use a contextual helper to pull this logic out of your template, for example:
{#overflow key=results}...and {.} more!{/overflow}
Notice how the logic has been removed from the template. Now you are not a hard and fast business rule.
Add the helper overflow
to the context:
{
"results": [ ... ],
"overflow": function(chunk, context, bodies, params) {
var results = context.resolve(params.key);
return results.length - 3;
}
}
0
source to share