Symfony2 twig render subdirectories

It seems like I'm having problems with nested rendering insertion

To explain further, I have the following view layout structure

resources .. config .. public .. etc .. views .. WeekBreakDown .. Export .. export.html.twig .. other.html.twig .. index.html.twig .. other.html.twig 

Now I can do the following without errors

 $this->render('NameBundle:WeekBreakDown:index.html.twig'); 

or

 $this->render('NameBundle:WeekBreakDown:other.html.twig'); 

I'm having trouble displaying the Export path.

I tried

 $this->render('NameBundle:WeekBreakDown:Export:index.html.twig'); 

and..

 $this->render('NameBundle:WeekBreakDown:Export\index.html.twig'); 

I get InvalidArgumentException: Unable to find template

+6
source share
2 answers

This should work

 $this->render('NameBundle:WeekBreakDown/Export:index.html.twig'); 
+18
source

therefore, the structure to be executed in the render () function, VendorAndNameBundle: sub / directories / path / in / views / folders: templateName.html.twig

+1
source

Source: https://habr.com/ru/post/944198/


All Articles