Donnie Donnie - 7 months ago 66
YAML Question

Symfony3: Passing variables to FrameworkBundle:Template:template

Just want to double check with the community, there are no chance to pass variables to a template rendered through FrameworkBundle:Template:template in the routing file right?

Thank you


It is by design:

But if you're rendering a simple template that doesn't need any data passed into it, you can avoid creating the controller entirely, by using the built-in FrameworkBundle:Template:template controller.

You can see that you can only pass three cache headers options and template name to render:

public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null)

So the anwser is: There is no chance to pass custom variables (excluding http cache headers options) to a template rendered through FrameworkBundle:Template:template.