Skip to content

Comparison operators are whitespace-sensitive #635

Open
@Shadowen

Description

@Shadowen

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions