Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash access to globals produces parse error #543

Open
imarkkinen opened this issue May 10, 2024 · 0 comments
Open

Hash access to globals produces parse error #543

imarkkinen opened this issue May 10, 2024 · 0 comments

Comments

@imarkkinen
Copy link

liquid-rust version: 0.26.4
rust version: 1.77.2
OS: MacOS

Shopify liquids in Ruby allow accessing globals at root level with hash access syntax while liquid-rust fails to parse a template that tries to access globals with hash access syntax.

Example in Ruby Shopify Liquid

Liquid::Template.parse("{{['my_variable']}}").render({"my_variable" => "value"})
=> "value"

while liquid-rust produces

let parser = liquid::ParserBuilder::with_stdlib().build().unwrap();
let tpl = parser.parse("{{['other']}}").unwrap();
let globals = liquid::object!({
        "my": {"variable": "value"}, "other": "other_value"
     });
 let res = tpl.render(&globals).unwrap();

called `Result::unwrap()` on an `Err` value: Error { inner: InnerError { msg: " --> 1:3\n  |\n1 | {{['other']}}\n  |   ^---\n  |\n  = expected Value", user_backtrace: [Trace { trace: None, context: [] }], cause: None } }

Is there plans to support hash access syntax to the root of globals? Or is it even feasible to do in liquid-rust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant