Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e203c40

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

File tree

Expand file treeCollapse file tree

1 file changed

+9
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-3
lines changed

‎cookbook/templating/global_variables.rst

Copy file name to clipboardExpand all lines: cookbook/templating/global_variables.rst
+9-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.