From e4d22f079be08b460b5e92510007c6fe9c5a310e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 10 Jan 2015 08:25:47 +0100 Subject: [PATCH] added documentation for the new absolute_url() and relative_path() Twig functions --- reference/twig_reference.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 1e23c89c381..e58a68cc813 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -355,6 +355,38 @@ Returns the absolute URL (with scheme and host) for the given route. If ``schemeRelative`` is enabled, it'll create a scheme-relative URL. More information in :ref:`book-templating-pages`. +absolute_url +~~~~~~~~~~~~ + +.. code-block:: jinja + + {{ absolute_url(path) }} + +``path`` + **type**: ``string`` + +Returns the absolute URL for the given absolute path. This is useful to convert +an existing path: + +.. code-block:: jinja + + {{ absolute_url(asset(path)) }} + +relative_path +~~~~~~~~~~~~~ + +.. code-block:: jinja + + {{ relative_path(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``. + expression ~~~~~~~~~~