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 Jul 29, 2015
1 parent d0af365 commit 7f38440
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 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:`ref-framework-assets-version`.
:ref:`book-templating-assets`. For asset versioning,
see :ref:`ref-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 @@ -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
Expand All @@ -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
Expand All @@ -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
~~~~~~~~~~
Expand Down

0 comments on commit 7f38440

Please sign in to comment.