-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
With the following setup:
use Twig\Environment;
use Twig\Loader\ArrayLoader;
$twig = new Environment(
new ArrayLoader([
'test' => '{{ test.test() }}',
]),
);
$twig->enableStrictVariables();
$template = $twig->load('test');attempting the following will succeed:
$template->render([
'test' => new class {
public function test()
{
return 'test';
}
},
]);while the following will fail:
$template->render([
'test' => [
'test' => fn() => 'test',
],
]);I am motivated to try the second one in tests, to avoid having to create complicated objects which might be tricky to do in an isolated way.
I'm curious to know if this is a design decision, or a niche which hasn't been popular enough to implement. I note the existence of two related issues:
but I'm not sure if they cover this case, or distinct ones.
Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels