liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Bracketed identifier parsing with and without dots

Open jg-rp opened this issue 2 years ago • 2 comments

Python liquid will successfully parse a chained identifier containing a bracketed index or identifier, followed immediately by another identifier, with no separating dot.

{{ products[0]title }}

Ruby Liquid will raise a Liquid::SyntaxError when parsing the above template, instead expecting {{ products[0].title }}. Python Liquid will accept either without error.

Similarly, Python Liquid will handle {{ products.[0].title }}, while Ruby Liquid will again raise a Liquid::SyntaxError.

jg-rp avatar Jan 11 '22 10:01 jg-rp

Related, Python Liquid will parse {{ products.0.title }} and {{ products[0].title }}. Ruby Liquid only accepts the later, raising a Liquid::SyntaxError for the former, whether in strict mode or not.

jg-rp avatar Jan 23 '22 12:01 jg-rp

And, with the initial example of {{ products[0]title }}, Ruby Liquid only raise an exception in strict mode. Lax mode does parse it successfully.

jg-rp avatar Jan 23 '22 12:01 jg-rp