To add to my comment I have created this answer (sorry for bad grammar / spelling).
If you want to pass a var in a template that needs to be always there, you can do the following (that's how I do this anyway).
Let's say we have a PageController with CRUD methods (update, delete, show etc etc). Instead of passing that var every time (or by modifying an already defined method), we could do the following: Let Twig 'fetch' the var by rendering a controller action. Twig will call the corresponding controller and will render that variable. Let's pretend that it's a sentence in a footer that needs to be rendered by variable on each page (to keep it simple).
We could write the following action in our PageController:
public function renderFooterAction() {
//Do your logic here, like retrieving the var from the database
//or something completely different.
//It could also be as easy as this:
$myVar = "This is a footer sentence";
//At the end we return a template
return $this->render('AcmeDemoBundle:Page:footer.html.twig', array(
'myVar' => $myVar,
));
}
The footer.html.twig page lives in YourBundle\Resources\views\Page\footer.html.twig. Depending on your needs it could be just like this (you can do everything in here like you can in a regular twig template, we're keeping it simple and only 'echoing' the variable):
{{ myVar }}
In your main template you can use the following piece of code:
{{ render(controller('AcmeDemoBundle:Page:renderFooter')) }}
You can also pass parameters inside your template along if you need to when rendering a piece of it, like:
{{ render(controller('AcmeDemoBundle:Page:footer', { 'maxArticles': 5 })) }}
The above thing is assuming you want to do a for loop in the template the controller renders.
As you can see, rendering a controller in a template is almost like rendering a 'normal' view, instead of returning a whole template, you just create smaller files with only the controller responsible output.
Hope this explanation helped you a bit :) Of course, if you're still confused, just ask for more clarity.
edit: It should also be possible to directly return the variable (I think), but can't remember that so quickly. Will add that if I can find it :)