Added Twig_Extension_Debug if app is in debug mode #305

Merged
merged 1 commit into from May 25, 2012

Projects

None yet

4 participants

Contributor
lyrixx commented Apr 16, 2012

No description provided.

Contributor
stof commented Apr 16, 2012

This was done initially in the PR adding it. But it has been reverted to avoid hard-to-debug issues when you have a template containing a dump call (it would work properly in your dev environment but throw an exception in your prod environment)

Contributor
lyrixx commented May 12, 2012

@stof but it's very usefull ... more over, every dev add this extension.

Contributor
stof commented May 12, 2012

@lyrixx The issue is that if it will be added only in debug mode and you forget to remove a dump call from your template, it will work properly in your dev environment (where Twig will be in debug mode with the extension) whereas the compilation of the template will fail in prod (because the function will not be defined anymore)

Contributor
lyrixx commented May 13, 2012

@stof Yes I understood. I did the patch... But every time, on a new projet, I copy/paste these lines to my projet. And I am not the only one. So I think we could add this feature into silex. (And why not in twig ? )

Contributor
stof commented May 13, 2012

@lyrixx When I said it was done previously, I was talking about Twig itself, not about Silex.

Contributor
lyrixx commented May 13, 2012

@stof ah ok ;) i did not understood that. But if this PR could be merge, it could be usefull. We need feedback here ?!

@fabpot fabpot added a commit that referenced this pull request May 25, 2012
@fabpot fabpot merged branch lyrixx/patch-twig-dump (PR #305)
Commits
-------

28c1b4c Added Twig_Extension_Debug if app is in debug mode

Discussion
----------

Added Twig_Extension_Debug if app is in debug mode

---------------------------------------------------------------------------

by stof at 2012-04-16T21:51:12Z

This was done initially in the PR adding it. But it has been reverted to avoid hard-to-debug issues when you have a template containing a dump call (it would work properly in your dev environment but throw an exception in your prod environment)

---------------------------------------------------------------------------

by lyrixx at 2012-05-12T14:12:09Z

@stof but it's very usefull ... more over, every dev add this extension.

---------------------------------------------------------------------------

by stof at 2012-05-12T23:36:27Z

@lyrixx The issue is that if it will be added only in debug mode and you forget to remove a dump call from your template, it will work properly in your dev environment (where Twig will be in debug mode with the extension) whereas the compilation of the template will fail in prod (because the function will not be defined anymore)

---------------------------------------------------------------------------

by lyrixx at 2012-05-13T13:21:20Z

@stof Yes I understood. I did the patch... But every time, on a new projet, I copy/paste these lines to my projet. And I am not the only one. So I think we could add this feature into silex. (And why not in twig ? )

---------------------------------------------------------------------------

by stof at 2012-05-13T18:08:36Z

@lyrixx When I said it was done previously, I was talking about Twig itself, not about Silex.

---------------------------------------------------------------------------

by lyrixx at 2012-05-13T19:32:38Z

@stof ah ok ;) i did not understood that. But if this PR could be merge, it could be usefull.  We need feedback here ?!
0452c31
@fabpot fabpot merged commit 28c1b4c into silexphp:master May 25, 2012
mchubby commented May 27, 2014

Hi,
I am using silex ~1.1 (twig >= 1.8 iirc)
How do you enable the dump function?

$app = new \Silex\Application();
$app['debug'] = true;
//...
$app->register(new TwigServiceProvider(), array(
    'twig.options' => array('debug'=>true),
//...
));

var_dump($app['twig']);

The var_dump() show the environment has debug property set to true and the extension "Twig_Extension_Debug" correctly loaded as well...

However rendering a form using $app['twig']->render raises an exception
Twig_Error_Syntax: Unknown tag name "dump"

Contributor
stof commented May 27, 2014

dump is a Twig function, not a Twig tag

mchubby commented May 27, 2014

Thanks @stof, now I feel embarrassed... It makes sense now.

Wrong:

{% dump(form) %}

Correct:

{{ dump(form) }}

It's in the docs, silly me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment