handlebars-rust icon indicating copy to clipboard operation
handlebars-rust copied to clipboard

Add test showing decorator behaviour in deep partials

Open rbtcollins opened this issue 10 months ago • 0 comments

Hi! this is really a bug report in reproducible form.

I was puzzling over how to replicate the behaviour from the decorator example which writes into the context, when that was happening in partials.

I eventually realised that the decorator is called with the root context, and modifies the root context, rather than the partials own context.

I'm not familiar with the implementation details in this version of handlebars (though I did write pybars a long time ago :P - anyhow, if there is a specified way (for instance, there's an jsonpath defining the view the partial is executing with), or some other API to use, that would be great!

The use case I have is - I have a data structure that has some poor ergonomics, and I want to derive nicers views on the data, just in time.

As an example, in a template I'd like to write

{{*filter attributename condition outputname}}
{{#each outputname}}{{this.name}}{{/each}}

or other similar things. There might be hundreds of different places in the original data structure that need this done - doing them all in the root template would be a poor fit (a possible workaround I did consider).

rbtcollins avatar Oct 15 '23 11:10 rbtcollins