Robbo_UK
Robbo_UK

Reputation: 12129

symfony2 twig render nesting sub directories

I seem to be having problems with twig render nesting

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 render the following without error

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

or

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

What I am having trouble with is rendering the Export path.

I have tried

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

and also..

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

I get the InvalidArgumentException: Unable to find template

Upvotes: 6

Views: 4270

Answers (2)

Alexandre Paquette
Alexandre Paquette

Reputation: 11

so the structure to follow in render() function is VendorAndNameBundle:sub/dirs/path/in/views/folder:templateName.html.twig

Upvotes: 1

Nisam
Nisam

Reputation: 2285

This should work

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

Upvotes: 19

Related Questions