After upgrading from 1.3 to 2.0, I'm receiving this error.

This is when using {{ vardumper(content) }} in a node.html.twig file.

Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("The last parameter of "Drupal\twig_vardumper\TwigExtension::drupalDump" for function "vardumper" must be an array with default value, eg. "array $arg = []".") in "themes/custom/themename/templates/content/node--foobar.html.twig". in Twig\Environment->compileSource() (line 798 of /app/vendor/twig/twig/src/Environment.php).

What's the correct new syntax?
Thanks!

Comments

alphex created an issue. See original summary.

alphex’s picture

Issue summary: View changes

edit, removing private info

kevinedmister’s picture

Also having this issue. Doesn't matter how you use, empty or with variable, it returns the same error. This is also true for {{ dump() }}. Started after the most recent update.

kevinedmister’s picture

Changing line 64 of /twig_vardumper/src/TwigExtension.php to:
...$vars to array $vars = [] seemed to work.

  • keopx committed 560fd28 on 8.x-2.x
    Issue #3143968: variable control with arguments.
    

  • keopx committed 1b0aafc on 3.0.x
    Issue #3143968: variable control with arguments.
    
keopx’s picture

Status: Active » Fixed

Thanks for issue :)

keopx’s picture

Status: Fixed » Closed (fixed)