Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e4d22f0

Browse filesBrowse files
committed
added documentation for the new absolute_url() and relative_path() Twig functions
1 parent ca54d55 commit e4d22f0
Copy full SHA for e4d22f0

File tree

Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed

‎reference/twig_reference.rst

Copy file name to clipboardExpand all lines: reference/twig_reference.rst
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,38 @@ Returns the absolute URL (with scheme and host) for the given route. If
355355
``schemeRelative`` is enabled, it'll create a scheme-relative URL. More
356356
information in :ref:`book-templating-pages`.
357357

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.