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

Allow registry to be cloned

Open rakshith-ravi opened this issue 5 years ago • 7 comments

Added Clone to registry.

Closes #396

rakshith-ravi avatar Nov 26 '20 08:11 rakshith-ravi

Okay yeah this doesn't seem to fix it. Let me try something else

rakshith-ravi avatar Nov 26 '20 08:11 rakshith-ravi

Can you use an Arc for this?

sunng87 avatar Nov 26 '20 08:11 sunng87

Yup. That's what I'm currently using locally. But I'm trying to get this to Clone directly so that we can make multiple copies of the registry that can work independent of each other. I'm trying to use generic parameters. Will update the PR once I get something running

rakshith-ravi avatar Nov 26 '20 08:11 rakshith-ravi

I'm afraid generic parameters may not work for this. Handlebars-rust uses a lot of dynamic dispatch in render and helper API, which makes helpers field not clone-able. I will think about this too.

sunng87 avatar Nov 26 '20 08:11 sunng87

By the way, I have made Registry clone-able in #395

sunng87 avatar Nov 29 '20 14:11 sunng87

Ahh, I see you made it into an Rc, to make it clone-able. While this works well, it is a little difficult if we need to have multiple copies of the Registry that can be cloned and modified independently. Sure, this can be a solution for now, don't get me wrong. I really appreciate the effort you're taking to fix this, and I would like to thank you for that. But if it's okay, I would like to take some more time to look for another way to make it really cloneable.

rakshith-ravi avatar Nov 29 '20 15:11 rakshith-ravi

@rakshith-ravi correct me if I'm wrong, but I think right now the registry can be modified independently - it's just the HelperDefs themselves that cannot be. The map itself is cloned so you can just replace the helpers with other ones.

SuperCuber avatar Dec 14 '20 10:12 SuperCuber