removed the debug tag (should be done in an extension)
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 13 Aug 2010 06:13:54 +0000 (08:13 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 13 Aug 2010 06:13:54 +0000 (08:13 +0200)
CHANGELOG
doc/02-Twig-for-Template-Designers.markdown
doc/03-Twig-for-Developers.markdown
lib/Twig/Node/Debug.php [deleted file]
lib/Twig/TokenParser/Debug.php [deleted file]

index e7d8cee..3d2e64b 100644 (file)
--- 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
index 92b9b85..85667a2 100644 (file)
@@ -809,24 +809,6 @@ But you can still create an alias by importing from the `_self` variable:
 
     <p>{{ forms.textarea('comment') }}</p>
 
-### 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
index e73bc63..5aca49b 100644 (file)
@@ -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 (file)
index 7f46b53..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2010 Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a debug node.
- *
- * @package    twig
- * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
- * @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 (file)
index aba2e9d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2009-2010 Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_TokenParser_Debug extends Twig_TokenParser
-{
-    /**
-     * Parses a token and returns a node.
-     *
-     * @param Twig_Token $token A Twig_Token instance
-     *
-     * @return Twig_NodeInterface A Twig_NodeInterface instance
-     */
-    public function parse(Twig_Token $token)
-    {
-        $lineno = $token->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';
-    }
-}