From 0cd7e6c9f31c7a39a78a91ea5222a71f394b0564 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 28 Jul 2015 23:37:58 +0200 Subject: [PATCH] Correctly document new twig functions --- reference/twig_reference.rst | 60 +++++++++++++++--------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 37f4c7a4475..227bb8d0774 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:`reference-framework-assets-version`. +:ref:`book-templating-assets`. For asset versioning, see +:ref:`reference-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 ~~~~ @@ -385,8 +363,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 @@ -395,18 +373,23 @@ 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. For example, assume +you're on the following page in your app: +``http://example.com/products/hover-board``. .. code-block:: jinja - {{ absolute_url(asset(path)) }} + {{ absolute_url('/human.txt') }} + {# http://example.com/human.txt #} + + {{ absolute_url('products_icon.png') }} + {# http://example.com/products/products_icon.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 @@ -415,10 +398,17 @@ 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. For example, assume +you're on the following page in your app: +``http://example.com/products/hover-board``. + +.. code-block:: jinja + + {{ relative_path('http://example.com/human.txt') }} + {# ../human.txt #} + + {{ relative_path('http://example.com/products/products_icon.png') }} + {# products_icon.png #} expression ~~~~~~~~~~