Skip to content

Commit 6c498d4

Browse files
committed
feature #4805 added documentation for the new absolute_url() and relative_path() Twig functions (fabpot)
This PR was merged into the master branch. Discussion ---------- added documentation for the new absolute_url() and relative_path() Twig functions | Q | A | ------------- | --- | Doc fix? | no | New docs? | symfony/symfony#13264 | Applies to | 2.7 | Fixed tickets | n/a Commits ------- e4d22f0 added documentation for the new absolute_url() and relative_path() Twig functions
2 parents 907ee0d + e4d22f0 commit 6c498d4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Diff for: reference/twig_reference.rst

+32
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)