twigphp/Twig — pull request #1559 by desyncr (2014-10-25 21:31:24+00:00)
Title: Added template information on debug mode

Searched on issues and PRs but could not find something like this so I gave it a try. I don't have a deep knowledge of twig code base so I don't know is this approach is the best (or correct) but I think the idea is useful.

On debug mode all included templates are wrapped by the path information for the template.
This is useful for easily moving in a code base which is not very well know to the developer (ie, a legacy code base or a new developer joining a project).

Example output:

...

The default format is:

%3$s%2$s%3$s%3$s

Given to sprintf with the following arguments:

$templatePath, $contents, PHP_EOL

Being `$templatePath` the template path (not resolved to file system, but in the format ie, `AcmeDemoBundle:Header:section/template.html.twig`).

`$contents` is the contents itself of the template already handled by doDisplay (ie, rendered).

`PHP_EOL` is only for formatting.

The format can be specified with the configuration argument `debug_format` passed in `$options` to `Twig_Environment`.