Mustache-style Context Lookups
Closed this issue · 1 comments
mAAdhaTTah commented
We're investigating "upgrading" from Mustache to Handlebars, and while it looks like the API to this project is very similar to Mustache.php, I came across some incompatibilities. Specifically, Mustache-style context lookups, whereby entering a block still allows you to reference a variable in the parent context. Mustache normally continues to look up the parent context until it finds the variable, whereas Handlebars appears to only look in the current context.
This makes it impossible to drop in Handlebars.php in place of Mustache.php. Two questions:
- How hard would it be to add this feature? If it's not too difficult, I may look into a PR for this.
- Are there any other incompatibilities between Mustache.php & Handlebars.php that you know of?
everplays commented
- Have a look at
get
method ofContext
class. It should not be very difficult to implement. Essentially, you need to use awhile
loop to move up the stack and try to get the variable. - This implementation of handlebars is based on https://github.com/bobthecow/mustache.php so they should work pretty much the same. Other than the problem that you mentioned, I am not aware of anything else but it is possible.