Skip to content

Commit feaf15d

Browse files
author
Chris Tickner
committed
[Book] [Templating] Made changes based on recommendations from @stof. Changed the section header to "Global Template Variables"
1 parent 73b280f commit feaf15d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

book/templating.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,18 +871,20 @@ is by default "web").
871871
The end result is a page that includes both the ``main.css`` and ``contact.css``
872872
stylesheets.
873873

874-
The ``app`` Global Variable
875-
---------------------------
874+
Global Template Variables
875+
-------------------------
876876

877-
Symfony2 will set a global template variable ``app`` on every request in
878-
both Twig and PHP template engines by default. The ``app`` variable will
879-
give you access to some application specific variables automatically:
877+
During each request, Symfony2 will set a global template variable ``app``
878+
in both Twig and PHP template engines by default. The ``app`` variable
879+
is a :class:`<Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables>`
880+
object which will give you access to some application specific variables
881+
automatically:
880882

881883
* ``app.security`` - The security context service.
882-
* ``app.user`` - The current user object. Equivalent to ``app.security.token.user``.
884+
* ``app.user`` - The current user object.
883885
* ``app.request`` - The request object.
884886
* ``app.session`` - The session object. Equivalent to ``app.request.session``.
885-
* ``app.environment`` - The current environment (dev, prod, etc)
887+
* ``app.environment`` - The current environment (dev, prod, etc).
886888
* ``app.debug`` - True if in debug mode. False otherwise.
887889

888890
.. configuration-block::
@@ -903,6 +905,11 @@ give you access to some application specific variables automatically:
903905
<p>Application Environment: <?php echo $app->getEnvironment() ?></p>
904906
<?php endif; ?>
905907

908+
.. tip::
909+
910+
You can set your own global template variables. See the cookbook example
911+
on :doc:`Global Variables</cookbook/templating/global_variables>`.
912+
906913
.. index::
907914
single: Templating; The templating service
908915

0 commit comments

Comments
 (0)