I got a simple CRUD-controller with a indexAction() to list all items. Now I want render this action within another template and change the .
{{ render(controller("MyBundle:MyEntity:index")) }}
Is there a predefined parameter to change the template? Sure its easy to pass this value, but I don't want reinvent the wheel.
There is no native parameter to change the template but you can pass an argument to the action defined by the render
method ...
{ render(controller('MyBundle:MyEntity:index', { 'template': 'MyBundle:ControllerName:foo.html.twig' })) }}
... and use it inside your controller action to decide which template to render.
class MyEntityController
{
public function indexAction($template = null)
{
// ... some code here
$template = $template ? $template : 'MyBundle:ControllerName:index.html.twig';
return $this->render(
$template,
array(
'variable' => $variable,
)
);
}