Skip to content
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

Use of "blank?" (Rails code) in Liquid #224

Open
fw42 opened this issue Jul 12, 2013 · 9 comments
Open

Use of "blank?" (Rails code) in Liquid #224

fw42 opened this issue Jul 12, 2013 · 9 comments

Comments

@fw42
Copy link
Contributor

fw42 commented Jul 12, 2013

See

'blank' => :blank?,

This doesn't work outside of Rails (Jekyll for instance).

@fw42
Copy link
Contributor Author

fw42 commented Jul 12, 2013

See #223.

@phoet
Copy link
Contributor

phoet commented Jan 23, 2014

we could add a default Object#blank? implementation and include it when there is none, i.e. in non rails projects.

@mikebridge
Copy link

I'm confused about blank---is it supposed to work by default? In my tests it's always evaluating to false:

{% assign space = " " %}{% if space == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY
{% if " " == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY
{% if "notblank" == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY
{% if myundefined == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY
{% assign myarray = "1,2" | split: "," %}{% if myarray == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY
{% assign myarray = "" | split: "," %}{% if myarray == blank %}TRUTHY{% else %}NOT TRUTHY{% endif %}
  --> NOT TRUTHY

@fw42
Copy link
Contributor Author

fw42 commented Aug 11, 2015

That's a bug, see #589. It works if activesupport (e.g. Rails) is present.

@mikebridge
Copy link

@fw42 Ok got that working, thanks!

@louwers
Copy link

louwers commented Jan 31, 2016

After installing activesupport by adding gem "activesupport" to my Gemfile, it still didn't work. Is there any way to trim whitespace so that I can compare with the empty string?

@pushrax
Copy link
Contributor

pushrax commented Jan 31, 2016

Since this is a language feature we may as well include it in Liquid.

@fw42
Copy link
Contributor Author

fw42 commented Jan 31, 2016

👎 to adding activesupport as a dependency. But I would be okay with reimplementing this method.

@pushrax
Copy link
Contributor

pushrax commented Jan 31, 2016

Right, I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants