-
Notifications
You must be signed in to change notification settings - Fork 42
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
Lacking full support for Closures #57
Comments
Hi! Thank you for taking the time to report this. In regards to your statement
Could you give some more detail as to what the effect is when this is done? (i.e. is an error visible or is an exception thrown? If so, what is the error message and/or stack-trace?). I've made two minimal test-cases based on the example you gave but both seem to work (using PHP 5.6 or PHP 7). Could you provide a minimal test-case that does not work? |
A failing test-case and an example of his workaround have been provided by @adjenks As he correctly states:
The failing case produces the following error:
|
@Potherca Thanks for working on the bug report. How goes the battle? |
Hi @adjenks, currently a lot of of my (spare) time is absorbed by other projects. |
On the releases page it states that there was added support for closures:
https://github.com/phptal/PHPTAL/releases
However, I found that when I used a closure directly on a template variable a closure would not work.
Only when using a "repeat" tag do closures appear to work. I'm not sure where you would fix this, but I found that closure support was provided in RepeatController.php in these lines:
So perhaps something similar needs to be done.
For example this will fail to load:
$details = function(){return 'some string';};
$template->details = $details;
But if $details was a closure that returned an array and it was iterrated over like so it works:
There might be a typo somewhere in that code but you should get the idea.
I wanted to use a closure to lazy load my template variable but it only worked when I used repeat, so I believe I found a problem. I found that I can temporarily work around this problem by returning a one element array and using the tal:repeat directive.
The text was updated successfully, but these errors were encountered: