From af6b4dead37971895469e59f3f48b2e3243428e0 Mon Sep 17 00:00:00 2001 From: Nicolas Sauveur Date: Fri, 12 Jan 2018 14:41:23 +0100 Subject: [PATCH 1/2] add missing twig dump construct added missing {% dump foo %} construct, in addition to {{ dump(foo) }}. The first one if the only one dumping to the debug toolbar. NB: copy pasted from the var_dumper component doc : https://symfony.com/doc/2.8/components/var_dumper.html --- templating/debug.rst | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/templating/debug.rst b/templating/debug.rst index 28742e83845..d58b0e1c5b0 100644 --- a/templating/debug.rst +++ b/templating/debug.rst @@ -33,10 +33,31 @@ for example, inside your controller:: The output of the ``dump()`` function is then rendered in the web developer toolbar. -The same mechanism can be used in Twig templates thanks to ``dump()`` function: +In a Twig template, two constructs are available for dumping a variable. +Choosing between both is mostly a matter of personal taste, still: + +* ``{% dump foo.bar %}`` is the way to go when the original template output + shall not be modified: variables are not dumped inline, but in the web + debug toolbar; +* on the contrary, ``{{ dump(foo.bar) }}`` dumps inline and thus may or not + be suited to your use case (e.g. you shouldn't use it in an HTML + attribute or a ``