@@ -73,6 +73,33 @@ to render the template originally) inside the template to render another templat
7373 <?php echo $view->render('hello.php', array('firstname' => $name)) ?>
7474 <?php endforeach ?>
7575
76+ Global Variables
77+ ----------------
78+
79+ Sometimes, you need to set a variable which is available in all templates
80+ rendered by an engine (like the ``$app `` variable when using the Symfony2
81+ framework). These variables can be set by using the
82+ :method: `Symfony\\ Component\\ Templating\\ PhpEngine::addGlobal ` method and they
83+ can be accessed in the template as normal variables::
84+
85+ $templating->addGlobal('ga_tracking', 'UA-xxxxx-x');
86+
87+ In a template:
88+
89+ ..code-block ::html+php
90+
91+ <p>The google tracking code is: <?php echo $ga_tracking ?></p>
92+
93+ ..caution ::
94+
95+ The global variables cannot be called ``this `` or ``view ``, since they are
96+ already used by the PHP engine.
97+
98+ ..note ::
99+
100+ The global variables can be overriden by a local variable in the template
101+ with the same name.
102+
76103Output Escaping
77104---------------
78105