5 The dump function was added in Twig 1.5.
7 The ``dump`` function dumps information about a template variable. This is
8 mostly useful to debug a template that does not behave as expected by
9 introspecting its variables:
17 The ``dump`` function is not available by default. You must add the
18 ``Twig_Extension_Debug`` extension explicitly when creating your Twig
21 $twig = new Twig_Environment($loader, array(
25 $twig->addExtension(new Twig_Extension_Debug());
27 Even when enabled, the ``dump`` function won't display anything if the
28 ``debug`` option on the environment is not enabled (to avoid leaking debug
29 information on a production server).
31 In an HTML context, wrap the output with a ``pre`` tag to make it easier to
42 Using a ``pre`` tag is not needed when `XDebug`_ is enabled and
43 ``html_errors`` is ``on``; as a bonus, the output is also nicer with
46 You can debug several variables by passing them as additional arguments:
50 {{ dump(user, categories) }}
52 If you don't pass any value, all variables from the current context are
61 Internally, Twig uses the PHP `var_dump`_ function.
66 * ``context``: The context to dump
68 .. _`XDebug`: http://xdebug.org/docs/display
69 .. _`var_dump`: http://php.net/var_dump