Comparison operators are whitespace-sensitive
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
I was messing around in Jekyll with Liquid and discovered this weird behaviour when I hit auto-format on an HTML file:
{% assign foo = "bar" %}
{% if foo == "bar" %}
true
{% else %}
false
{% endif %}
gives the result true, whereas
{% assign foo = "bar" %}
{% if foo=="bar" %}
true
{% else %}
false
{% endif %}
gives the result false.
Furthermore,
{% assign foo = "" %}
{% if foo=="bar" %}
true
{% else %}
false
{% endif %}
gives the result true, as though Liquid is evaluating against the empty string.
Can anyone replicate this? Is this documented (and I missed it)? I can't seem to find any notes on how whitespace is relevant to Liquid, and I would expect it to obey the same whitespace rules as HTML (ie. ignore all unnecessary whitespace).
#428 relevant?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two Liquid snippets to confirm how whitespace changes comparison results, then trace the comparison parsing path in the Liquid implementation. Done means comparisons behave consistently regardless of optional surrounding whitespace, with regression coverage for the shown cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100