diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 867bc439972..7a8199097ae 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -111,7 +111,8 @@ asset Returns a public path to ``path``, which takes into account the base path set for the package and the URL path. More information in -:ref:`book-templating-assets`. For asset versioning, see :ref:`ref-framework-assets-version`. +:ref:`book-templating-assets`. For asset versioning, +see :ref:`ref-framework-assets-version`. assets_version ~~~~~~~~~~~~~~ @@ -126,29 +127,6 @@ assets_version Returns the current version of the package, more information in :ref:`book-templating-assets`. -absolute_url -~~~~~~~~~~~~ - -.. code-block:: jinja - - {{ absolute_url(asset(path, packageName)) }} - -``path`` - **type**: ``string`` -``packageName`` - **type**: ``string`` | ``null`` **default**: ``null`` - -Returns the absolute URL that corresponds to the given asset path and package. -More information in :ref:`book-templating-assets`. For configuring the base URLs, -:ref:`ref-framework-assets-base-urls`. - -The absolute URLs generated with this function ignore the asset versioning. -Combine it with the ``assets_version()`` function to append the version number: - -.. code-block:: jinja - - {{ absolute_url(asset('logo.png')) ~ '?' ~ assets_version('images') }} - form ~~~~ @@ -384,8 +362,8 @@ information in :ref:`book-templating-pages`. absolute_url ~~~~~~~~~~~~ -.. versionadded:: 2.6 - The ``absolute_url`` function was introduced in Symfony 2.7 +.. versionadded:: 2.7 + The ``absolute_url()`` function was introduced in Symfony 2.7. .. code-block:: jinja @@ -394,18 +372,22 @@ absolute_url ``path`` **type**: ``string`` -Returns the absolute URL for the given absolute path. This is useful to convert -an existing path: +Returns the absolute URL from the passed relative path. Assume the following +code was used to render ``http://example.com/sub/list.html``: .. code-block:: jinja - {{ absolute_url(asset(path)) }} + {{ absolute_url('/human.txt') }} + {# http://example.com/human.txt #} + + {{ absolute_url('something.png') }} + {# http://example.com/sub/something.png #} relative_path ~~~~~~~~~~~~~ -.. versionadded:: 2.6 - The ``relative_path`` function was introduced in Symfony 2.7 +.. versionadded:: 2.7 + The ``relative_path()`` function was introduced in Symfony 2.7. .. code-block:: jinja @@ -414,10 +396,16 @@ relative_path ``path`` **type**: ``string`` -Returns a relative path for the given absolute path (based on the current -request path). For instance, if the current path is -``/article/news/welcome.html``, the relative path for ``/article/image.png`` is -``../images.png``. +Returns the relative path from the passed absolute URL. Assume the following +code was used to render ``http://example.com/sub/list.html``: + +.. code-block:: jinja + + {{ relative_path('http://example.com/human.txt') }} + {# ../human.txt #} + + {{ relative_path('http://example.com/sub/something.png') }} + {# something.png #} expression ~~~~~~~~~~