From c25a1efc80834aceb6135a174c40babd6acd219b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 14 Aug 2022 15:01:53 +0200 Subject: [PATCH] Make doc clearer --- doc/filters/replace.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/doc/filters/replace.rst b/doc/filters/replace.rst index 5761a2196f..0c38b73bfe 100644 --- a/doc/filters/replace.rst +++ b/doc/filters/replace.rst @@ -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::