-
Notifications
You must be signed in to change notification settings - Fork 24
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
supply()
template method does not work when same engine instance is used to render more templates
#31
Comments
Hi @brad-jones and thanks for your interest in Foil! Sorry, but I tested your exact example and I think your problem is in Using |
I created a Gist with all the files I used to test this issue https://gist.github.com/Giuseppe-Mazzapica/6e3ae0aeb8e9fce54818 You can download it, and after |
Ok I got to the bottom of it, I knew I wasn't crazy. Let me know what you think. For now my quick fix is to make sure the Foil engine is newed up each time it is requested from my DI container. Cheers Brad |
supply()
template method does not work when same engineinstance is used to render more templates
supply()
template method does not work when same engineinstance is used to render more templatessupply()
template method does not work when same engine instance is used to render more templates
@brad-jones Ok, I see the issue. This is something that was noted already and fixed when sections are rendered using template inheritance (see #25), but was not fixed when sections are used with I'll fix this as soon as possible. |
See #31 Template have to get sections via section factory, that way after a rendering they are reset.
@brad-jones it should be fixed now. Can you please require Foil from I ran the test in your Gist (https://gist.github.com/brad-jones/6279ce76cbedc2584675) replacing "require": {
"foil/foil": "*"
} with "require": {
"foil/foil": "dev-master"
} in Thanks for reporting! |
@Giuseppe-Mazzapica mate you are a legend! I just got into the office, I will get back to you in the next few hours with some real world testing in my wordpress theme. |
@Giuseppe-Mazzapica feel free to release v0.6.4. Seems to be working fine for me Thanks again. |
@brad-jones thanks a lot for reporting and testing. |
As per the title, here is my use case.
/views/layouts/master.php
/views/default.php
This next bit is overly simplified, I am running a PHP-DI container inside a Wordpress theme with a PSR-7 router. But none of that should matter (I don't think).
The Result:
Expected Result:
If I modify the master layout to look like this, I get the expected result:
The issue appears to be here:
https://github.com/FoilPHP/Foil/blob/master/src/Template/Template.php#L172
$this->sections
is empty. I have tried to follow how the sections are defined and added to the stack but between dependency injection, events, magic methods & the fact it's now 20mins past midnight. I got confused rather quickly. I will have another look in the morning with fresh eyes.All the same the supply method certainly doesn't appear to work or at least it doesn't work exactly like the Laravel Blade @yield syntax. Maybe I am missing something obvious??? I'll probably discover my error the second I hit the "Submit new issue" button.
The text was updated successfully, but these errors were encountered: