Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you probably need is the <code>include</code> tag which includes another template.</p> <pre><code>{% include 'FooBundle::partial.html.twig' %} </code></pre> <p>Template inclusion is for simple cases, where you just need things like partials.</p> <p>The <code>render</code> tag is for invoking controllers, doing more complex things, or if your template can't access the variables needed to display easily. Doing that the kernel creates a new request as if it came as a standalone request. In fact using ESI it could be a standalone request to that controller.<a href="http://symfony.com/doc/current/book/http_cache.html#using-esi-in-symfony2" rel="nofollow" title="Using ESI in symfony2">See here for details</a>. Because of that, you can't get the main request object, there is probably no main request object because you use ESI or because you create a route for that controller and invoke it via AJAX or whatever. Relying on the the information that your controller is invoked via a sub-request is not supported by the framework as I know, and I think it's intentional. You have to pass all information in query parameters.</p> <p>Your example isn't correct, it would be like this:</p> <pre><code>{% render 'FooBundle:MyController:actionName' ... %} </code></pre> <p>You have to have a <code>FooBundle\Controller\MyControllerController</code> class like this for tihs to work.</p> <pre><code>namespace FooBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class MyControllerController extends Controller { public function actionNameAction() { ... } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload