-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partials don't work #1
Comments
Thanks. This should be fixed in master now. Let me know if you still have problems. |
Further explanation: Contexts weren't always stored this way internally, and partials must have broken when it switched over. Apparently I need more test cases for partials :) The context is always encapsulated in an array (inside a Mustache instance) because a context is actually a cascading set of contexts. For example, inside an iterable block, the context will contain both the original template context, as well as the context for the current $i in the foreach loop. If a variable is present in the current context, that one is rendered, else it is looked for in the parent context. Your patch works fine in instances where only one context exists. To solve the general case of the partials problem, however, the set of contexts needs to be flattened before passing into the partial's view. This is done by the new Mustache::_flattenContext() call. |
Thanks for the quick solution and explanation :) |
I'm hesitant to set properties on an object of an arbitrary class. If the class implements I made the assumption that the root context was either a Mustache instance ($this) or a context array passed to the constructor or render() method. You bring up a good point, that the object passed may very well be an instance of some arbitrary class. Let me look into this and get back to you, k? |
Okay. I think eeb5b24 might be just the thing you need. Wanna do me a favor and check out the |
Never mind, that breaks context in partials... I'm going to take another shot at it. |
Okay. I think I got it this time. Check out |
Wow, great work!!! |
Great :) I'll mark this as closed and merge the fix into master. Thanks for your help. |
Solving PHP 8.1 deprecation warning: htmlspecialchars(): Passing null to parameter bobthecow#1 ($string) of type string is deprecated
Hi, I don't know if there is something wrong in my test code, but the partials seems don't work properly.
This is my test code: http://pastebin.com/FDsmbch5
The output of this script, don't show the list of childs.
Whit this stupid patch http://pastebin.com/tSgaN6mu partials works fine.
Seems that when rendering a partial, the context is encapsulated recursively in another array.
Greetings
The text was updated successfully, but these errors were encountered: