@@ -111,7 +111,8 @@ asset
111
111
112
112
Returns a public path to ``path ``, which takes into account the base path
113
113
set for the package and the URL path. More information in
114
- :ref: `book-templating-assets `. For asset versioning, see :ref: `ref-framework-assets-version `.
114
+ :ref: `book-templating-assets `. For asset versioning,
115
+ see :ref: `ref-framework-assets-version `.
115
116
116
117
assets_version
117
118
~~~~~~~~~~~~~~
@@ -129,25 +130,50 @@ Returns the current version of the package, more information in
129
130
absolute_url
130
131
~~~~~~~~~~~~
131
132
133
+ .. versionadded :: 2.7
134
+ The ``absolute_url() `` function was introduced in Symfony 2.7.
135
+
132
136
.. code-block :: jinja
133
137
134
- {{ absolute_url(asset( path, packageName) ) }}
138
+ {{ absolute_url(path) }}
135
139
136
140
``path ``
137
141
**type **: ``string ``
138
- ``packageName ``
139
- **type **: ``string `` | ``null `` **default **: ``null ``
140
142
141
- Returns the absolute URL that corresponds to the given asset path and package.
142
- More information in :ref: `book-templating-assets `. For configuring the base URLs,
143
- :ref: `ref-framework-assets-base-urls `.
143
+ Returns the absolute URL from the passed relative path. Assume the following
144
+ code was used to render ``http://example.com/sub/list.html ``:
145
+
146
+ .. code-block :: jinja
147
+
148
+ {{ absolute_url('/human.txt') }}
149
+ {# http://example.com/human.txt #}
150
+
151
+ {{ absolute_url('something.png') }}
152
+ {# http://example.com/sub/something.png #}
153
+
154
+ relative_path
155
+ ~~~~~~~~~~~~~
156
+
157
+ .. versionadded :: 2.7
158
+ The ``relative_path() `` function was introduced in Symfony 2.7.
159
+
160
+ .. code-block :: jinja
161
+
162
+ {{ relative_path(path) }}
144
163
145
- The absolute URLs generated with this function ignore the asset versioning.
146
- Combine it with the ``assets_version() `` function to append the version number:
164
+ ``path ``
165
+ **type **: ``string ``
166
+
167
+ Returns the relative path from the passed absolute URL. Assume the following
168
+ code was used to render ``http://example.com/sub/list.html ``:
147
169
148
170
.. code-block :: jinja
149
171
150
- {{ absolute_url(asset('logo.png')) ~ '?' ~ assets_version('images') }}
172
+ {{ relative_path('http://example.com/human.txt') }}
173
+ {# ../human.txt #}
174
+
175
+ {{ relative_path('http://example.com/sub/something.png') }}
176
+ {# something.png #}
151
177
152
178
form
153
179
~~~~
0 commit comments