I created a new bundle where twig files shall be included. From default there is already a twig file added by the generate bundle command line (in src/TestBundle/Resources/views/test.html.twig
). There is also the render-command added automatically in IndexAction:
return $this->render('TestBundle:test.html.twig', $data);
But when I call the IndexAction, I get a template not found error, and the error says, that symfony only looked in
/app/Resources/views,
/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form
but not in /src/TestBundle/...
Why does symfony ignore the bundle Resources? And how could I change that?
I had the same issue with Symfony 3.3, and eventually, through trial and error, discovered that you have to use @ followed by the bundle name, BUT omit the word 'Bundle' from the namespace. So...
@MyFabulousUserBundle/Email/reset_password.html.twig
...did not work, but:
@MyFabulousUser/Email/reset_password.html.twig
did!
I was having the same issue, I could use my template with the syntax:
$this->render('@TestBundle/Test/test.html.twig', $data);
but if I tried to use the syntax:
$this->render('TestBundle:Test:test.html.twig', $data);
I had the same error message. After a long and fastidious search, it turned out that what was missing was this line in my config.yml
:
framework:
templating:
engines: ['twig']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With