Skip to content

Commit 638063f

Browse files
javiereguiluzxabbuh
authored andcommitted
minor #9042 add missing twig dump construct (hellomedia, javiereguiluz)
This PR was merged into the 2.8 branch. Discussion ---------- 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 Commits ------- 6e4f084 Minor reword af6b4de add missing twig dump construct
1 parent ac99784 commit 638063f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

templating/debug.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ for example, inside your controller::
3333
The output of the ``dump()`` function is then rendered in the web developer
3434
toolbar.
3535

36-
The same mechanism can be used in Twig templates thanks to ``dump()`` function:
36+
In a Twig template, you can use the ``dump`` utility as a function or a tag:
37+
38+
* ``{% dump foo.bar %}`` is the way to go when the original template output
39+
shall not be modified: variables are not dumped inline, but in the web
40+
debug toolbar;
41+
* on the contrary, ``{{ dump(foo.bar) }}`` dumps inline and thus may or not
42+
be suited to your use case (e.g. you shouldn't use it in an HTML
43+
attribute or a ``<script>`` tag).
3744

3845
.. code-block:: html+twig
3946

4047
{# app/Resources/views/article/recent_list.html.twig #}
41-
{{ dump(articles) }}
48+
{# the contents of this variable are sent to the Web Debug Toolbar #}
49+
{% dump articles %}
4250

4351
{% for article in articles %}
52+
{# the contents of this variable are display on the web page #}
53+
{{ dump(article) }}
54+
4455
<a href="/article/{{ article.slug }}">
4556
{{ article.title }}
4657
</a>

0 commit comments

Comments
 (0)