Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

themichaelhall/twig-console-dump

Repository files navigation

Twig Console Dump

Build Status AppVeyor codecov.io StyleCI License Latest Stable Version Total Downloads

Twig extension for dumping a variable to the browser console.

Requirements

  • PHP >= 7.1
  • Twig >= 2.4

Install with composer

$ composer require michaelhall/twig-console-dump

Basic usage

After enabling this extension, the dump() function can be used to dump a variable to the browser console.

Internally, this is done via inline JavaScript using console.log() functions.

The variable is only dumped to the console if debug mode is enabled in Twig, otherwise nothing is outputted.

Dump a variable

{{ dump(foo) }}

Result

Dump a variable

Dump a variable with a label

{{ dump(foo, 'Bar') }}

Result

Dump a variable with a label

Additional options

{{ dump(foo, 'Bar', {'script-nonce': 'baz'}) }}
  • script-nonce: The nonce attribute to use in the inline <script> tag for CSP-protection.

License

MIT

About

Twig extension for dumping a variable to browser console

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages