31392f311546f8cdb9cb4091e55fb1f43f466df4
[yaffs-website] / vendor / twig / twig / doc / filters / replace.rst
1 ``replace``
2 ===========
3
4 The ``replace`` filter formats a given string by replacing the placeholders
5 (placeholders are free-form):
6
7 .. code-block:: jinja
8
9     {{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
10
11     {# outputs I like foo and bar
12        if the foo parameter equals to the foo string. #}
13
14     {# using % as a delimiter is purely conventional and optional #}
15
16     {{ "I like this and --that--."|replace({'this': foo, '--that--': "bar"}) }}
17
18     {# outputs I like foo and bar #}
19
20 Arguments
21 ---------
22
23 * ``from``: The placeholder values
24
25 .. seealso:: :doc:`format<format>`