Im trying to embed a controller inside a twig template. Its documented here: http://symfony.com/doc/current/quick_tour/the_view.html and have read various questions on stackoverflow about it like this one: How to insert a Controller in Twig with "render" in Symfony 2.2?
However, when I try to embed my controller i get an error: "The function 'controller' does not exist"
My twig template looks like this:
<div class="section">
<div id="a" class="section_column">
{{ render(controller('MySymfonyBundle:AccessPage:load', {'page_id':'1'})) }}
</div>
</div>
The controller that is being embedded does some db selects etc then renders another view to include inside this template.
This is the full error:
array(
['message'] =>
'Uncaught PHP Exception Twig_Error_Syntax: "The function "controller" does not exist in "<div id="{{ identifier }}" class="section">
<div id="a" class="section_column">
{{ render(controller('ABCBundle:Site:grabPage', {'page_id':'1'})) }}
</div>
</div>" at line 3" at /www/vendor/twig/twig/lib/Twig/ExpressionParser.php line 555'
['context'] =>
array(
['exception'] =>
array(
)
)
)
this just doesnt seem to work =( Where am I going wrong?