Skip to content

Logical operators in conditions #225

Closed

Description

@fw42

Yeah, so there is this:

{% if true && false %} wrong {% endif %}
{% if false || true %} right {% else %} wrong {% endif %}

Guess what that does (hint: It doesn't throw a syntax error).

How do we want to handle this? @boourns @arthurnn @hornairs

Activity

  1. fw42 commented on Jul 12, 2013

    @fw42
    ContributorAuthor

    Thanks @Tetsuro for noticing.

  2. fw42 commented on Jul 12, 2013

    @fw42
    ContributorAuthor

    I guess we should throw an error?

  3. trishume commented on Jul 26, 2013

    @trishume
    Contributor

    There is actually a test that asserts that this bug exists:

    def test_unexpected_characters_silently_eat_logic
      markup = "true && false"
      assert_template_result(' YES ',"{% if #{markup} %} YES {% endif %}")
      markup = "false || true"
      assert_template_result('',"{% if #{markup} %} YES {% endif %}")
    end
  4. fw42 commented on Jul 26, 2013

    @fw42
    ContributorAuthor
  5. jamesmacaulay commented on Jul 26, 2013

    @jamesmacaulay
    Contributor

    @fw42 that's part of the ParsingQuirksTest suite, which exists in order to document quirks in Liquid's parsing logic. Historically there have been a number of cases where we've fixed things like this and inadvertently break a bunch of shop's templates which relied on the quirk in a bad way. As with all of the tests in that file, it doesn't mean we can't change the behaviour, but the test is there as a regression to raise a red flag when we do change it to say "we need to be careful about breaking templates".

  6. jamesmacaulay commented on Jul 26, 2013

    @jamesmacaulay
    Contributor

    Looking again at the commit in which I introduced that test, it looks like I had fixed something previously in a different way which broke this weird quirk:

    11dc18b

  7. ghost assigned on Aug 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions