Sam
Sam

Reputation: 14586

Twig: adding twig extension debug from config file

According to TWIG documentation, in order to use the dump function I should first add the extension debug like so:

$twig = new Twig_Environment($loader, array(
'debug' => true,
// ...
 ));
$twig->addExtension(new Twig_Extension_Debug());

But how do I do that from config.yml ? I use symfony2.

Upvotes: 4

Views: 4648

Answers (1)

Ahmed Siouani
Ahmed Siouani

Reputation: 13891

It should be defined as follow,

# app/config/config.yml
services:
    custom.twig.extension.debug:
        class: Twig_Extension_Debug
        tags:
             - { name: 'twig.extension' }

Upvotes: 6

Related Questions