Skip to content

Commit e203c40

Browse files
committed
[#2865] Minor proofreading and tweaks thanks to @xabbuh and @stof about the services as global Twig variables
1 parent 493a135 commit e203c40

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cookbook/templating/global_variables.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ Referencing Services
8686
--------------------
8787

8888
Instead of using static values, you can also set the value to a service.
89-
Whenever the global variabele is accessed in the template, the service will be
89+
Whenever the global variable is accessed in the template, the service will be
9090
requested from the service container and you get access to that object.
9191

92-
This is done by prefixing the string with ``@``, which you already know from
93-
injecting a service:
92+
.. note::
93+
94+
The service is not loaded lazily. In other words, as soon as Twig is
95+
loaded, your service is instantiated, even if you never use that global
96+
variable.
97+
98+
To define a service as a global Twig variable, prefix the string with ``@``.
99+
This should feel familiar, as it's the same syntax you use in service configuration.
94100

95101
.. configuration-block::
96102

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy