You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As exemplified in the `Symfony Cookbook <http://symfony.com/doc/current/cookbook/templating/global_variables.html>`_ it is possible to make a variable to be accessible to all the templates you use by configuring your `app/config/config.yml` file:
17
+
18
+
.. code-block:: yaml
19
+
20
+
# app/config/config.yml
21
+
smarty:
22
+
# ...
23
+
globals:
24
+
ga_tracking: UA-xxxxx-x
25
+
26
+
Now, the variable ga_tracking is available in all Smarty templates:
27
+
28
+
.. code-block:: html+smarty
29
+
30
+
<p>Our google tracking code is: {$ga_tracking} </p>
This technique can speed up your website by eliminating extra whitespace characters and thus reducing page size. It removes HTML comments (except ConditionalComments) and reduces multiple whitespace to a single space everywhere but ``<script>``, ``<pre>``, ``<textarea>`` [#]_.
39
+
40
+
To enable this feature add the ``trimwhitespace`` output filter in ``app/config/config.yml``:
Copy file name to clipboardExpand all lines: Resources/doc/usage.rst
+1-20Lines changed: 1 addition & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,23 +90,4 @@ Please see `Symfony2 - Template Naming and Locations <http://symfony.com/doc/2.0
90
90
.. note::
91
91
92
92
The `.html.smarty` extension can simply be replaced by `.smarty`. We are prefixing with `.html` to stick with the Symfony convention of defining the format (`.html`) and engine (`.smarty`) for each template.
93
-
94
-
Injecting variables into all templates (i.e. Global Variables)
As exemplified in the `Symfony Cookbook <http://symfony.com/doc/current/cookbook/templating/global_variables.html>`_ it is possible to make a variable to be accessible to all the templates you use by configuring your `app/config/config.yml` file:
98
-
99
-
.. code-block:: yaml
100
-
101
-
# app/config/config.yml
102
-
smarty:
103
-
# ...
104
-
globals:
105
-
ga_tracking: UA-xxxxx-x
106
-
107
-
Now, the variable ga_tracking is available in all Smarty templates:
108
-
109
-
.. code-block:: html+smarty
110
-
111
-
<p>Our google tracking code is: {$ga_tracking} </p>
0 commit comments