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

Index access to globals produces parse error #543

Open
imarkkinen opened this issue May 10, 2024 · 1 comment · May be fixed by #560
Open

Index access to globals produces parse error #543

imarkkinen opened this issue May 10, 2024 · 1 comment · May be fixed by #560

Comments

@imarkkinen
Copy link

imarkkinen commented May 10, 2024

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

Shopify liquids in Ruby allow accessing globals at root level with index syntax while liquid-rust fails to parse a template that tries to access globals with index 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 index access syntax to the root of globals? Or is it even feasible to do in liquid-rust?

@imarkkinen imarkkinen changed the title Hash access to globals produces parse error Index access to globals produces parse error Sep 15, 2024
@imarkkinen
Copy link
Author

Attempted fix in #560

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

Successfully merging a pull request may close this issue.

1 participant