Skip to content

Commit 6fe9edf

Browse files
committed
minor #3734 Make doc clearer for the replace filter (fabpot)
This PR was merged into the 2.x branch. Discussion ---------- Make doc clearer for the replace filter Closes #3733 Commits ------- c25a1ef Make doc clearer
2 parents 48fba37 + c25a1ef commit 6fe9edf

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

doc/filters/replace.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
``replace``
22
===========
33

4-
The ``replace`` filter formats a given string by replacing the placeholders
5-
(placeholders are free-form):
4+
The ``replace`` filter replaces placeholders in a string (the placeholder
5+
format is free-form):
66

77
.. code-block:: twig
88
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. #}
9+
{{ "I like %this% and %that%."|replace({'%this%': fruit, '%that%': "oranges"}) }}
10+
{# if the "fruit" variable is set to "apples", #}
11+
{# it outputs "I like apples and oranges" #}
1312
1413
{# 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 #}
14+
{{ "I like this and --that--."|replace({'this': fruit, '--that--': "oranges"}) }}
15+
{# outputs "I like apples and oranges" #}
1916
2017
Arguments
2118
---------
2219

23-
* ``from``: The placeholder values
20+
* ``from``: The placeholder values as a hash
2421

2522
.. seealso::
2623

0 commit comments

Comments
 (0)