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
<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
* `macro`
* `import`
* `set`
- * `debug`
* Filters:
+++ /dev/null
-<?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")
- ;
- }
-}
+++ /dev/null
-<?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';
- }
-}