I am using
"dustjs-helpers": "1.6.0", with "dustjs-linkedin": "^2.6.0" .
In my template I need to check an OR condition like
if( cherry === true || berry === true)
path/to/template1/
else
path/to/template2/
How do I accomplish this with the Dust helpers?
Because you're testing two different variables, you'll need two different truth tests.
You can either put this logic into your template, or into a small helper. I'll show you both ways.
Let's assume that your context looks like this:
Template method
This method requires dustjs-helpers >= 1.6.2
You'll have to include two
{@eq}checks. Because you're using such an up-to-date version of Dust, you have access to the{@any}and{@none}helpers.You have to manually override the
keytoberryin the second truth test.Less-Awesome Template Method
Works with all versions of dustjs-helpers.
Cons: this doesn't scale, it's ugly, it repeats data.
Helper method
Doesn't require dustjs-helpers at all.
Pros: you can add more conditions without changing your template.