Closed shYkiSto closed 6 months ago
Fixed an issue with substitutions when one overrides any other substitutions used for the same partial template during multi level inheritance(in other words all that happening inside other partial template).
Here's the test sample:
{{!subPartial.mustache}}
Haloha! {{$replace}}replace me{{/replace}}
{{!partial.mustache}}
{{<subPartial}}
{{$replace}}removed1{{/replace}}
{{/subPartial}}
{{<subPartial}}
{{$replace}}removed2{{/replace}}
{{/subPartial}}
{{!main.mustache}}
{{>partial}}
Without the fix it renders:
Haloha! removed1 Haloha! removed1
When second replacement should be removed2
.
The fix is that the stackSubs & stackPartials are updated with prototypical inheritance. So one partial doesn't affect others. And instead just inherits all the information from the parent.
Can split up my work into 2 separated PR.. but not sure if they're going to be ever accepted...
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
There was new feature proposed which is in line with the current spec(which isn't updating for years :() here: https://github.com/mustache/spec/issues/52
It's been implemented in some of the Mustache implementations already and is backward compatible. It should allow us avoid issues when some key is missing in top context and engine is looking for that variable in parent contexts.