8000 Correctly document new twig functions · symfony/symfony-docs@7f38440 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f38440

Browse files
committed
Correctly document new twig functions
1 parent d0af365 commit 7f38440

File tree

1 file changed

+23
-35
lines changed

1 file changed

+23
-35
lines changed

reference/twig_reference.rst

Lines changed: 23 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:`ref-framework-assets-version`.
114+
:ref:`book-templating-assets`. For asset versioning,
115+
see :ref:`ref-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

@@ -384,8 +362,8 @@ information in :ref:`book-templating-pages`.
384362
absolute_url
385363
~~~~~~~~~~~~
386364

387-
.. versionadded:: 2.6
388-
The ``absolute_url`` function was introduced in Symfony 2.7
365+
.. versionadded:: 2.7
366+
The ``absolute_url()`` function was introduced in Symfony 2.7.
389367

390368
.. code-block:: jinja
391369
@@ -394,18 +372,22 @@ absolute_url
394372
``path``
395373
**type**: ``string``
396374

397-
Returns the absolute URL for the given absolute path. This is useful to convert
398-
an existing path:
375+
Returns the absolute URL from the passed relative path. Assume the following
376+
code was used to render ``http://example.com/sub/list.html``:
399377

400378
.. code-block:: jinja
401379
402-
{{ absolute_url(asset(path)) }}
380+
{{ absolute_url('/human.txt') }}
381+
{# http://example.com/human.txt #}
382+
383+
{{ absolute_url('something.png') }}
384+
{# http://example.com/sub/something.png #}
403385
404386
relative_path
405387
~~~~~~~~~~~~~
406388

407-
.. versionadded:: 2.6
408-
The ``relative_path`` function was introduced in Symfony 2.7
389+
.. versionadded:: 2.7
390+
The ``relative_path()`` function was introduced in Symfony 2.7.
409391

410392
.. code-block:: jinja
411393
@@ -414,10 +396,16 @@ relative_path
414396
``path``
415397
**type**: ``string``
416398

417-
Returns a relative path for the given absolute path (based on the current
418-
request path). For instance, if the current path is
419-
``/article/news/welcome.html``, the relative path for ``/article/image.png`` is
420-
``../images.png``.
399+
Returns the relative path from the passed absolute URL. Assume the following
400+
code was used to render ``http://example.com/sub/list.html``:
401+
402+
.. code-block:: jinja
403+
404+
{{ relative_path('http://example.com/human.txt') }}
405+
{# ../human.txt #}
406+
407+
{{ relative_path('http://example.com/sub/something.png') }}
408+
{# something.png #}
421409
422410
expression
423411
~~~~~~~~~~

0 commit comments

Comments
 (0)
0