diff --git a/cookbook/templating/global_variables.rst b/cookbook/templating/global_variables.rst index 4067cfb40fb..11cce2f0c2c 100644 --- a/cookbook/templating/global_variables.rst +++ b/cookbook/templating/global_variables.rst @@ -41,7 +41,50 @@ Now, the variable ``ga_tracking`` is available in all Twig templates:
The google tracking code is: {{ ga_tracking }}
-It's that easy! You can also take advantage of the built-in :ref:`book-service-container-parameters` +It's that easy! + +Referencing Services +-------------------- + +Instead of using static values, you can also set the value to a service. +Whenever the global variabele is accessed in the template, the service will be +requested from the service container and you get access to that object. + +This is done by prefixing the string with ``@``, which you already know from +injecting a service: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + twig: + # ... + globals: + user_management: "@acme_user.user_management" + + .. code-block:: xml + + +Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: