mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-09 00:46:31 +00:00
feature #2341 feature #2045 Adds Twig_NodeCaptureInterface for nodes that capture all output (brandonkelly)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2341).
Discussion
----------
feature #2045 Adds Twig_NodeCaptureInterface for nodes that capture all output
This implements the feature originally suggested by #2045, but specifically in the manner suggested by #2340, which I think is more consistent with existing Twig code.
Commits
-------
bc6a9133 feature #2045 Adds Twig_NodeCaptureInterface for nodes that capture all output
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Twig_Node_Set extends Twig_Node
|
||||
class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
|
||||
{
|
||||
public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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 node that will capture any nested displayable nodes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface Twig_NodeCaptureInterface
|
||||
{
|
||||
}
|
||||
+2
-2
@@ -386,8 +386,8 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
throw new Twig_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
|
||||
}
|
||||
|
||||
// bypass "set" nodes as they "capture" the output
|
||||
if ($node instanceof Twig_Node_Set) {
|
||||
// bypass nodes that will "capture" the output
|
||||
if ($node instanceof Twig_NodeCaptureInterface) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user