@@ -135,7 +135,7 @@ Throughout this chapter, template examples will be shown in both Twig and PHP.
135
135
web designers everywhere.
136
136
137
137
Twig can also do things that PHP can't, such as whitespace control,
138
- sandboxing, automatic HTML escaping, manual contextual output escaping,
138
+ sandboxing, automatic HTML escaping, manual contextual output escaping,
139
139
and the inclusion of custom functions and filters that only affect templates.
140
140
Twig contains little features that make writing templates easier and more concise.
141
141
Take the following example, which combines a loop with a logical ``if ``
@@ -1019,46 +1019,12 @@ assets won't be cached when deployed. For example, ``/images/logo.png`` might
1019
1019
look like ``/images/logo.png?v2 ``. For more information, see the :ref: `ref-framework-assets-version `
1020
1020
configuration option.
1021
1021
1022
- .. _`book-templating-version-by-asset` :
1022
+ If you need absolute URLs for assets, use the ``absolute_url() `` Twig function
1023
+ as follows:
1023
1024
1024
- If you need to set a version for a specific asset, you can set the fourth
1025
- argument (or the ``version `` argument) to the desired version:
1026
-
1027
- .. configuration-block ::
1028
-
1029
- .. code-block :: html+jinja
1030
-
1031
- <img src="{{ asset('images/logo.png', version='3.0') }}" alt="Symfony!" />
1032
-
1033
- .. code-block :: html+php
1034
-
1035
- <img src="<?php echo $view['assets']->getUrl(
1036
- 'images/logo.png',
1037
- null,
1038
- false,
1039
- '3.0'
1040
- ) ?>" alt="Symfony!" />
1041
-
1042
- If you don't give a version or pass ``null ``, the default package version
1043
- (from :ref: `ref-framework-assets-version `) will be used. If you pass ``false ``,
1044
- versioned URL will be deactivated for this asset.
1045
-
1046
- If you need absolute URLs for assets, you can set the third argument (or the
1047
- ``absolute `` argument) to ``true ``:
1048
-
1049
- .. configuration-block ::
1050
-
1051
- .. code-block :: html+jinja
1052
-
1053
- <img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" />
1054
-
1055
- .. code-block :: html+php
1025
+ .. code-block :: html+jinja
1056
1026
1057
- <img src="<?php echo $view['assets']->getUrl(
1058
- 'images/logo.png',
1059
- null,
1060
- true
1061
- ) ?>" alt="Symfony!" />
1027
+ <img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" />
1062
1028
1063
1029
.. index ::
1064
1030
single: Templating; Including stylesheets and JavaScripts
@@ -1216,7 +1182,7 @@ automatically:
1216
1182
1217
1183
.. versionadded :: 2.6
1218
1184
The global ``app.security `` variable (or the ``$app->getSecurity() ``
1219
- method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user ``
1185
+ method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user ``
1220
1186
(``$app->getUser() ``) and ``is_granted() `` (``$view['security']->isGranted() ``)
1221
1187
instead.
1222
1188
0 commit comments