From 30de2dae95076fffb76f3a5c9b47b6ead4cd4901 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 13 Aug 2010 08:13:54 +0200 Subject: [PATCH] removed the debug tag (should be done in an extension) --- CHANGELOG | 1 + doc/02-Twig-for-Template-Designers.markdown | 18 ------- doc/03-Twig-for-Developers.markdown | 1 - lib/Twig/Node/Debug.php | 68 --------------------------- lib/Twig/TokenParser/Debug.php | 42 ---------------- 5 files changed, 1 insertions(+), 129 deletions(-) delete mode 100644 lib/Twig/Node/Debug.php delete mode 100644 lib/Twig/TokenParser/Debug.php diff --git a/CHANGELOG b/CHANGELOG index e7d8cee..3d2e64b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Backward incompatibilities: * the self special variable has been renamed to _self + * removed the debug tag (should be done in an extension) * fixed trans tag when no vars are used in plural form * fixed race condition when writing template cache * fixed inheritance diff --git a/doc/02-Twig-for-Template-Designers.markdown b/doc/02-Twig-for-Template-Designers.markdown index 92b9b85..85667a2 100644 --- a/doc/02-Twig-for-Template-Designers.markdown +++ b/doc/02-Twig-for-Template-Designers.markdown @@ -809,24 +809,6 @@ But you can still create an alias by importing from the `_self` variable:

{{ forms.textarea('comment') }}

-### Debug - -Whenever a template does not work as expected, the debug tag can be used to -output the content of the current context: - - [twig] - {% debug %} - -You can also output a specific variable or an expression: - - [twig] - {% debug items %} - - {% debug post.body %} - -Note that this tag only works when the `debug` option of the environment is -set to `true`. - ### Internationalization (new in Twig 0.9.6) When the `i18n` extension is enabled, use the `trans` block to mark parts in diff --git a/doc/03-Twig-for-Developers.markdown b/doc/03-Twig-for-Developers.markdown index e73bc63..5aca49b 100644 --- a/doc/03-Twig-for-Developers.markdown +++ b/doc/03-Twig-for-Developers.markdown @@ -267,7 +267,6 @@ The `core` extension defines all the core features of Twig: * `macro` * `import` * `set` - * `debug` * Filters: diff --git a/lib/Twig/Node/Debug.php b/lib/Twig/Node/Debug.php deleted file mode 100644 index 7f46b53..0000000 --- a/lib/Twig/Node/Debug.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version SVN: $Id$ - */ -class Twig_Node_Debug extends Twig_Node -{ - public function __construct(Twig_Node_Expression $expr = null, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile($compiler) - { - $compiler->addDebugInfo($this); - - $compiler - ->write("if (\$this->env->isDebug()) {\n") - ->indent() - ; - - if (null === $this->expr) { - // remove embedded templates (macros) from the context - $compiler - ->write("\$vars = array();\n") - ->write("foreach (\$context as \$key => \$value) {\n") - ->indent() - ->write("if (!\$value instanceof Twig_Template) {\n") - ->indent() - ->write("\$vars[\$key] = \$value;\n") - ->outdent() - ->write("}\n") - ->outdent() - ->write("}\n") - ->write("print_r(\$vars);\n") - ; - } else { - $compiler - ->write("print_r(") - ->subcompile($this->expr) - ->raw(");\n") - ; - } - - $compiler - ->outdent() - ->write("}\n") - ; - } -} diff --git a/lib/Twig/TokenParser/Debug.php b/lib/Twig/TokenParser/Debug.php deleted file mode 100644 index aba2e9d..0000000 --- a/lib/Twig/TokenParser/Debug.php +++ /dev/null @@ -1,42 +0,0 @@ -getLine(); - - $expr = null; - if (!$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) { - $expr = $this->parser->getExpressionParser()->parseExpression(); - } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Debug($expr, $lineno, $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @param string The tag name - */ - public function getTag() - { - return 'debug'; - } -} -- 1.7.2.5