Skip to content

Index access to globals produces parse error #543

@imarkkinen

Description

@imarkkinen

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions