Make doc clearer

This commit is contained in:
Fabien Potencier
2022-08-14 15:01:53 +02:00
parent f2cb718bdb
commit c25a1efc80
+8 -11
View File
@@ -1,26 +1,23 @@
``replace``
===========
The ``replace`` filter formats a given string by replacing the placeholders
(placeholders are free-form):
The ``replace`` filter replaces placeholders in a string (the placeholder
format is free-form):
.. code-block:: twig
{{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
{# outputs I like foo and bar
if the foo parameter equals to the foo string. #}
{{ "I like %this% and %that%."|replace({'%this%': fruit, '%that%': "oranges"}) }}
{# if the "fruit" variable is set to "apples", #}
{# it outputs "I like apples and oranges" #}
{# using % as a delimiter is purely conventional and optional #}
{{ "I like this and --that--."|replace({'this': foo, '--that--': "bar"}) }}
{# outputs I like foo and bar #}
{{ "I like this and --that--."|replace({'this': fruit, '--that--': "oranges"}) }}
{# outputs "I like apples and oranges" #}
Arguments
---------
* ``from``: The placeholder values
* ``from``: The placeholder values as a hash
.. seealso::