blob: 5761a2196fb79bc85ade784541d2e740857c686f [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``replace``
2===========
3
4The ``replace`` filter formats a given string by replacing the placeholders
5(placeholders are free-form):
6
7.. code-block:: twig
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
20Arguments
21---------
22
23* ``from``: The placeholder values
24
25.. seealso::
26
27 :doc:`format<format>`