All values in Liquid are truthy except nil and false. (#26)

* All values in Liquid are truthy except nil and false.

* The falsy values are null, undefined and false.
This commit is contained in:
chenos
2017-03-21 12:25:11 +08:00
committed by Jun Yang
parent 2ae6874397
commit 66774865f4
5 changed files with 24 additions and 9 deletions
+2 -3
View File
@@ -43,12 +43,11 @@ function evalValue(str, scope) {
}
function isTruthy(val) {
if (val instanceof Array) return !!val.length;
return !!val;
return !isFalsy(val);
}
function isFalsy(val) {
return !isTruthy(val);
return false === val || undefined === val || null === val;;
}
module.exports = {