Ask about specification of Liquid variable key (Referencing handles)

Ask about specification of Liquid variable key (Referencing handles)

koshigoe
Shopify Partner
3 0 0

I need document write about Liquid variable.

 

I read following document, but there is not enough information for me.
https://shopify.dev/docs/api/liquid/basics#referencing-handles

 

Where is it write about more detail about Liquid variable?

I'd like to know detail about variable key in square bracket like `var["key"]`.

 

 

1. Is it possible to use backslash escape like `var["key-with-quote\""]` ?

 

The Ruby library liquid gem, it occur syntax error when using backslash escape.
Is this behavior a bug or specification?

 

 

2. Some characters have special meaning in the variable key?

 

The Ruby library liquid gem, it handle `item["key]"]` as `item[key]`.
I expected the key `"key]"` is literal string, but library handle as variable `key`.
Is this behavior a bug or specification?

 

The Ruby library liquid gem(v5.4.0), it handle `item["item['key']"]` as `item[item["key"]]`.
But unreleased version (master branch) handle `item["item['key']"]` as `item["item['key']"]`.
I expected the key `"item['key']"` is literal string, but the library of released version handle as variable `item['key']`.
Which behavior is right?

 

 

----

 

I also posted to GitHub Issue.

https://github.com/Shopify/liquid/issues/1740

Reply 1 (1)

koshigoe
Shopify Partner
3 0 0

Should I refer to liquidjs (npm) instead of liquid gem?

 

Which Liquid implementation is correct?