mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
Make doc clearer
This commit is contained in:
+8
-11
@@ -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::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user