Check if it is empty.
If the value is an array, returns true if there are no elements.
If the value is a string, the leading and trailing spaces are trimmed and then checked.
Parameters:
val: any
Character strings, arrays, objects, etc. to be checked.
// If the value is an array.
// results in: true
hbs.compile("{{empty val}}")({"val":[]});
// results in: true
hbs.compile("{{#if (empty val)}}true{{else}}false{{/if}}")({"val":[]});
// results in: false
hbs.compile("{{empty val}}")({"val":["foo"]});
// If the value is a string.
// results in: false
hbs.compile("{{empty val}}")({"val":"Hello"});
// results in: true
hbs.compile("{{empty val}}")({"val":""});
// results in: true
hbs.compile("{{empty val}}")({"val":" "});
notEmpty
Check that it is not empty.
If the value is an array, returns true if there is an element.
If the value is a string, the leading and trailing spaces are trimmed and then checked.
Parameters:
val: any
Character strings, arrays, objects, etc. to be checked.
// If the value is an array.
// results in: false
hbs.compile("{{notEmpty val}}")({"val":[]});
// results in: false
hbs.compile("{{#if (notEmpty val)}}true{{else}}false{{/if}}")({"val":[]});
// results in: true
hbs.compile("{{notEmpty val}}")({"val":["foo"]});
// If the value is a string.
// results in: true
hbs.compile("{{notEmpty val}}")({"val":"Hello"});
// results in: false
hbs.compile("{{notEmpty val}}")({"val":""});
// results in: false
hbs.compile("{{notEmpty val}}")({"val":" "});
Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
Parameters:
args: ...any
Any number of boolean parameters.
// results in: true
hbs.compile("{{and a b}}")({"a":true,"b":true});
// results in: true
hbs.compile("{{#if (and a b)}}true{{else}}false{{/if}}")({"a":true,"b":true});
// results in: false
hbs.compile("{{and a b}}")({"a":false,"b":true});
// results in: false
hbs.compile("{{#if (and a b)}}true{{else}}false{{/if}}")({"a":false,"b":true});
or
Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
Parameters:
args: ...any
Any number of boolean parameters.
// results in: true
hbs.compile("{{or a b}}")({"a":true,"b":false});
// results in: true
hbs.compile("{{#if (or a b)}}true{{else}}false{{/if}}")({"a":true,"b":false});
// results in: false
hbs.compile("{{or a b}}")({"a":false,"b":false});
// results in: false
hbs.compile("{{#if (or a b)}}true{{else}}false{{/if}}")({"a":false,"b":false});
coalesce
Returns the first non-falsy value from the parameter list.
Checks for the first non-false parameter.
Parameters:
args: ...any
Any number of parameters.
// results in: foo
hbs.compile("{{coalesce a b c}}")({"a":"foo","b":"bar","c":"baz"});
// results in: bar
hbs.compile("{{coalesce a b c}}")({"a":"","b":"bar","c":"baz"});
includes
Returns true if the array contains a particular value, false if it does not.