As exemplified in the Symfony Cookbook it is possible to make a variable to be accessible to all the templates you use by configuring your app/config/config.yml file:
# app/config/config.yml
smarty:
# ...
globals:
ga_tracking: UA-xxxxx-x
Now, the variable ga_tracking is available in all Smarty templates:
<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>
[1].
To enable this feature add the trimwhitespace
output filter in app/config/config.yml
:
# app/config/config.yml
# Smarty configuration
smarty:
options:
autoload_filters:
output: [trimwhitespace]
[1] | http://stackoverflow.com/a/9207456/545442 |