Skip to content

Commit 0cd7e6c

Browse files
committed
Correctly document new twig functions
1 parent bc18ff1 commit 0cd7e6c

File tree

1 file changed

+25
-35
lines changed

1 file changed

+25
-35
lines changed

reference/twig_reference.rst

Lines changed: 25 additions & 35 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:`reference-framework-assets-version`.
114+
:ref:`book-templating-assets`. For asset versioning, see
115+
:ref:`reference-framework-assets-version`.
115116

116117
assets_version
117118
~~~~~~~~~~~~~~
@@ -126,29 +127,6 @@ assets_version
126127
Returns the current version of the package, more information in
127128
:ref:`book-templating-assets`.
128129

129-
absolute_url
130-
~~~~~~~~~~~~
131-
132-
.. code-block:: jinja
133-
134-
{{ absolute_url(asset(path, packageName)) }}
135-
136-
``path``
137-
**type**: ``string``
138-
``packageName``
139-
**type**: ``string`` | ``null`` **default**: ``null``
140-
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`.
144-
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:
147-
148-
.. code-block:: jinja
149-
150-
{{ absolute_url(asset('logo.png')) ~ '?' ~ assets_version('images') }}
151-
152130
form
153131
~~~~
154132

@@ -385,8 +363,8 @@ information in :ref:`book-templating-pages`.
385363
absolute_url
386364
~~~~~~~~~~~~
387365

388-
.. versionadded:: 2.6
389-
The ``absolute_url`` function was introduced in Symfony 2.7
366+
.. versionadded:: 2.7
367+
The ``absolute_url()`` function was introduced in Symfony 2.7.
390368

391369
.. code-block:: jinja
392370
@@ -395,18 +373,23 @@ absolute_url
395373
``path``
396374
**type**: ``string``
397375

398-
Returns the absolute URL for the given absolute path. This is useful to convert
399-
an existing path:
376+
Returns the absolute URL from the passed relative path. For example, assume
377+
you're on the following page in your app:
378+
``http://example.com/products/hover-board``.
400379

401380
.. code-block:: jinja
402381
403-
{{ absolute_url(asset(path)) }}
382+
{{ absolute_url('/human.txt') }}
383+
{# http://example.com/human.txt #}
384+
385+
{{ absolute_url('products_icon.png') }}
386+
{# http://example.com/products/products_icon.png #}
404387
405388
relative_path
406389
~~~~~~~~~~~~~
407390

408-
.. versionadded:: 2.6
409-
The ``relative_path`` function was introduced in Symfony 2.7
391+
.. versionadded:: 2.7
392+
The ``relative_path()`` function was introduced in Symfony 2.7.
410393

411394
.. code-block:: jinja
412395
@@ -415,10 +398,17 @@ relative_path
415398
``path``
416399
**type**: ``string``
417400

418-
Returns a relative path for the given absolute path (based on the current
419-
request path). For instance, if the current path is
420-
``/article/news/welcome.html``, the relative path for ``/article/image.png`` is
421-
``../images.png``.
401+
Returns the relative path from the passed absolute URL. For example, assume
402+
you're on the following page in your app:
403+
``http://example.com/products/hover-board``.
404+
405+
.. code-block:: jinja
406+
407+
{{ relative_path('http://example.com/human.txt') }}
408+
{# ../human.txt #}
409+
410+
{{ relative_path('http://example.com/products/products_icon.png') }}
411+
{# products_icon.png #}
422412
423413
expression
424414
~~~~~~~~~~

0 commit comments

Comments
 (0)