@@ -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 ``
@@ -1021,46 +1021,12 @@ assets won't be cached when deployed. For example, ``/images/logo.png`` might
1021
1021
look like ``/images/logo.png?v2 ``. For more information, see the :ref: `ref-framework-assets-version `
1022
1022
configuration option.
1023
1023
1024
- .. _`book-templating-version-by-asset` :
1024
+ If you need absolute URLs for assets, use the ``absolute_url() `` Twig function
1025
+ as follows:
1025
1026
1026
- If you need to set a version for a specific asset, you can set the fourth
1027
- argument (or the ``version `` argument) to the desired version:
1028
-
1029
- .. configuration-block ::
1030
-
1031
- .. code-block :: html+jinja
1032
-
1033
- <img src="{{ asset('images/logo.png', version='3.0') }}" alt="Symfony!" />
1034
-
1035
- .. code-block :: html+php
1036
-
1037
- <img src="<?php echo $view['assets']->getUrl(
1038
- 'images/logo.png',
1039
- null,
1040
- false,
1041
- '3.0'
1042
- ) ?>" alt="Symfony!" />
1043
-
1044
- If you don't give a version or pass ``null ``, the default package version
1045
- (from :ref: `ref-framework-assets-version `) will be used. If you pass ``false ``,
1046
- versioned URL will be deactivated for this asset.
1047
-
1048
- If you need absolute URLs for assets, you can set the third argument (or the
1049
- ``absolute `` argument) to ``true ``:
1050
-
1051
- .. configuration-block ::
1052
-
1053
- .. code-block :: html+jinja
1054
-
1055
- <img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" />
1056
-
1057
- .. code-block :: html+php
1027
+ .. code-block :: html+jinja
1058
1028
1059
- <img src="<?php echo $view['assets']->getUrl(
1060
- 'images/logo.png',
1061
- null,
1062
- true
1063
- ) ?>" alt="Symfony!" />
1029
+ <img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" />
1064
1030
1065
1031
.. index ::
1066
1032
single: Templating; Including stylesheets and JavaScripts
@@ -1218,7 +1184,7 @@ automatically:
1218
1184
1219
1185
.. versionadded :: 2.6
1220
1186
The global ``app.security `` variable (or the ``$app->getSecurity() ``
1221
- method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user ``
1187
+ method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user ``
1222
1188
(``$app->getUser() ``) and ``is_granted() `` (``$view['security']->isGranted() ``)
1223
1189
instead.
1224
1190
0 commit comments