Skip to content

Commit

Permalink
Correctly document new twig functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed May 5, 2016
1 parent bc18ff1 commit 0cd7e6c
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions reference/twig_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~
Expand All @@ -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
~~~~

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
~~~~~~~~~~
Expand Down

0 comments on commit 0cd7e6c

Please sign in to comment.