You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.
I've modified a fork of this package that makes it possible to pass arguments to attribute helpers, besides some other useful features. The fork has been released as dalgard:jade.
I will keep the new package in sync with the original, should there be any updates, and generally continue maintenance until, hopefully, the two packages can be merged.
Regarding your case, I'm using some global logic helpers to do it in a reasonably elegant fashion:
The trick works, because falsy values are not output in the template – if isChecked is falsy, nothing happens. The logic helpers that I use look like this:
// Return the last truthy argumentTemplate.registerHelper("$and",function(...args){if(args[args.length-1]instanceofSpacebars.kw)args.pop();return_.reduce(args,function(memo,item){returnmemo&&item;});});// Return the first truthy argumentTemplate.registerHelper("$or",function(...args){if(args[args.length-1]instanceofSpacebars.kw)args.pop();return_.reduce(args,function(memo,item){returnmemo||item;});});// Return the first or second string depending on conditionTemplate.registerHelper("$tern",function(condition,first,second){returncondition ? first : second;});
P.S. You can syntax highlight Jade like this:
```jade
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'd like to use something like
But it seems the meteor-jade does not support ternary operator, so instead I must use
See, a lot of code are redundant if ternary operator is not allowed.
Is there a better way to achieve the operation?
The text was updated successfully, but these errors were encountered: