-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All values in Liquid are truthy except nil and false. #26
Conversation
src/syntax.js
Outdated
} | ||
|
||
function isFalsy(val) { | ||
return !isTruthy(val); | ||
return false === val || undefined === val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding, ruby's nil
is null
or undefined
in javascript.
So
return false === val || undefined === val || null === val;
var src = '{% for i in (1..5) reversed limit:2 %}{{ i }}{% endfor %}'; | ||
return expect(liquid.parseAndRender(src, ctx)) | ||
.to.eventually.equal('21'); | ||
}); | ||
|
||
it('should support for reversed in the first position', function() { | ||
it('should support for reversed in the middle position', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
For details, see https://shopify.github.io/liquid/basics/truthy-and-falsy/