Skip to content

Commit 8cd7718

Browse files
fabpotjaviereguiluz
authored andcommitted
added documentation for the new absolute_url() and relative_path() Twig functions
1 parent 9a0282a commit 8cd7718

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

reference/twig_reference.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,38 @@ Returns the absolute URL (with scheme and host) for the given route. If
358358
``schemeRelative`` is enabled, it'll create a scheme-relative URL. More
359359
information in :ref:`book-templating-pages`.
360360

361+
absolute_url
362+
~~~~~~~~~~~~
363+
364+
.. code-block:: jinja
365+
366+
{{ absolute_url(path) }}
367+
368+
``path``
369+
**type**: ``string``
370+
371+
Returns the absolute URL for the given absolute path. This is useful to convert
372+
an existing path:
373+
374+
.. code-block:: jinja
375+
376+
{{ absolute_url(asset(path)) }}
377+
378+
relative_path
379+
~~~~~~~~~~~~~
380+
381+
.. code-block:: jinja
382+
383+
{{ relative_path(path) }}
384+
385+
``path``
386+
**type**: ``string``
387+
388+
Returns a relative path for the given absolute path (based on the current
389+
request path). For instance, if the current path is
390+
``/article/news/welcome.html``, the relative path for ``/article/image.png`` is
391+
``../images.png``.
392+
361393
expression
362394
~~~~~~~~~~
363395

0 commit comments

Comments
 (0)