and
Perform a logical AND (&&).
{{# and([EXPRESSION...]) }} TRUTHY {{else}} FALSY {{/ and }}
and( x, y )
works just like x && y
. You can use it directly within a magic tag like:
import {stache} from "can";
var view = stache(`{{# and(this.x, this.y) }} YES {{else}} NO {{/ and }}`);
var fragment = view({ x: 1, y: true});
console.log(fragment.firstChild.nodeValue) //-> YES
document.body.append(fragment);
You can use and
in a nested expression like:
{{# if( and(this.x, this.y) ) }} YES {{else}} NO {{/ and }}
and
also takes multiple arguments. and( x, y, z )
works just like x && y && z
.