From 38e47a3e94bf28d3d939bd67e0597c84e8467595 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 10 Aug 2024 11:32:28 +0200 Subject: [PATCH] Add a note about how to escape a string interpolation in a string --- doc/templates.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/templates.rst b/doc/templates.rst index e09a6a018..b0f5b9a1c 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -589,6 +589,16 @@ inserted into the string: {{ "foo #{bar} baz" }} {{ "foo #{1 + 2} baz" }} +.. tip:: + + String interpolations can be ignored by escaping them with a backslash + (``\``): + + .. code-block:: twig + + {# outputs foo #{1 + 2} baz #} + {{ "foo \#{1 + 2} baz" }} + Math ~~~~