Skip to content

if tag condition, the token args is empty after updating from 10.19.1 to 10.20.0 or later #796

@sidneyprins

Description

@sidneyprins

Hello,

We have a string

  • Hello, {% if name %} {{ name }} {% else %} user {% endif %}

When we update from 10.19.1 to 10.20.0 or later, our test starts to fail. We use the LiquidJS engine to read out all the different kinds of tokens and figure out which are required and optional.

The token if normally gets args filled with name in this case, but since updating it returns an empty string.

Version 10.19.1

See args

Image

Version 10.20.0 or higher

See args

Image

I have done some digging and found these changes.

Image

Link:
File tags/if.ts, line 15 till 21

If I revert these changes, it works again.

When I run that specific function item.token.tokenizer.readFilteredValue() I get the following error.

invalid value expression: "", line:1, col:18
>> 1| Hello, {% if name  %} {{ name }} {% else %} user {% endif %}
                       ^
TokenizationError: invalid value expression: "", line:1, col:18
    at Tokenizer.error (/private/var/www/vhosts/mailer/node_modules/liquidjs/dist/liquid.node.js:1999:16)
    at Tokenizer.assert (/private/var/www/vhosts/mailer/node_modules/liquidjs/dist/liquid.node.js:2003:24)
    at Tokenizer.readFilteredValue (/private/var/www/vhosts/mailer/node_modules/liquidjs/dist/liquid.node.js:1841:14)
    at eval (eval at <anonymous> (/private/var/www/vhosts/mailer/server/src/lib/helpers/liquid_helpers.ts:25:1), <anonymous>:1:22)
...

We have tried various versions of writing the strings, such as seen on https://liquidjs.com/tags/if.html, like

  • {% if customer.name == "kevin" %} blabla {% endif %}

We're not sure how to make a fix for this part, can you help us?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions