-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
How do I check if a variable is defined? #89
Comments
why not check against nil. Nil and "doesn't exist" are the same concept in liquid (unlike JS).
|
Ah. Thanks. |
What if the possibly undefined variable is a boolean, and you want to run the block if it's |
then you can use |
What about negating this check? In my case the variable Although
Is there a more succinct form e.g. |
There is an |
the unless tag is the inverse of the if tag and sounds like it will work for you |
But if I want to check for a condition OR if the variable is not defined at all
I would prefer to write it in as few statements as possible because the code else if is large. |
For anyone who stumbles here and - like me - was looking for this check in the context of a Jekyll list filter (e.g. Unfortunately, it's pretty unclear from the language documentation what the difference between |
I do this by
I think |
Say (in Jekyll, for example) I want to check if a certain variable, say
header_image
was defined and do something if it is, and something else if it isn't. How would I do that?The text was updated successfully, but these errors were encountered: