Skip to content

Commit 2515ef9

Browse files
committed
Correctly document new twig functions
1 parent d0af365 commit 2515ef9

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

reference/twig_reference.rst

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ asset
111111

112112
Returns a public path to ``path``, which takes into account the base path
113113
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`.
115116

116117
assets_version
117118
~~~~~~~~~~~~~~
@@ -129,25 +130,50 @@ Returns the current version of the package, more information in
129130
absolute_url
130131
~~~~~~~~~~~~
131132

133+
.. versionadded:: 2.7
134+
The ``absolute_url()`` function was introduced in Symfony 2.7.
135+
132136
.. code-block:: jinja
133137
134-
{{ absolute_url(asset(path, packageName)) }}
138+
{{ absolute_url(path) }}
135139
136140
``path``
137141
**type**: ``string``
138-
``packageName``
139-
**type**: ``string`` | ``null`` **default**: ``null``
140142

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) }}
144163
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``:
147169

148170
.. code-block:: jinja
149171
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 #}
151177
152178
form
153179
~~~~

0 commit comments

Comments
 (0)