Skip to content

Support for recursive lookup? #729

@wez

Description

@wez

I'm evaluating handlebars-rust where it needs to be able to support this sort of recursive lookup scenario as part of supporting some legacy applications with existing templates:

{{#each children}}
   outer={{{outer_value}}}
   inner={{{inner_value}}}
{{/each}}

with input data:

{
  "children": [{"inner_value": "foo"}],
  "outer_value": "outer"
}

the legacy application runs with handlebars.js running in compat mode:

Handlebars deviates from Mustache slightly in that it does not perform recursive lookup by default. The compile time compat flag must be set to enable this functionality. Users should note that there is a performance cost for enabling this flag. The exact cost varies by template, but it's recommended that performance sensitive operations should avoid this mode and instead opt for explicit path references.

so the template renders as:

outer=outer
inner=foo

handlebars-rust renders it as:

outer=
inner=foo

Is adding optional support for this kind of recursive lookup something that you'd want in handlebars-rust?

I'm willing to look at working up a PR to support this if you can point me to the roughly the right place!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions