]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/doc/filters/url_encode.rst
twig implementation
[github/wallabag/wallabag.git] / vendor / twig / twig / doc / filters / url_encode.rst
1 ``url_encode``
2 ==============
3
4 .. versionadded:: 1.12.3
5 Support for encoding an array as query string was added in Twig 1.12.3.
6
7 The ``url_encode`` filter percent encodes a given string as URL segment
8 or an array as query string:
9
10 .. code-block:: jinja
11
12 {{ "path-seg*ment"|url_encode }}
13 {# outputs "path-seg%2Ament" #}
14
15 {{ "string with spaces"|url_encode(true) }}
16 {# outputs "string%20with%20spaces" #}
17
18 {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
19 {# outputs "param=value&foo=bar" #}
20
21 .. note::
22
23 Internally, Twig uses the PHP `urlencode`_ (or `rawurlencode`_ if you pass
24 ``true`` as the first parameter) or the `http_build_query`_ function.
25
26 .. _`urlencode`: http://php.net/urlencode
27 .. _`rawurlencode`: http://php.net/rawurlencode
28 .. _`http_build_query`: http://php.net/http_build_query