[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/twig/twig/src/Node/ -> SpacelessNode.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of Twig.
   5   *
   6   * (c) Fabien Potencier
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Twig\Node;
  13  
  14  use Twig\Compiler;
  15  
  16  /**
  17   * Represents a spaceless node.
  18   *
  19   * It removes spaces between HTML tags.
  20   *
  21   * @deprecated since Twig 2.7, to be removed in 3.0
  22   *
  23   * @author Fabien Potencier <fabien@symfony.com>
  24   */
  25  class SpacelessNode extends Node implements NodeOutputInterface
  26  {
  27      public function __construct(Node $body, int $lineno, string $tag = 'spaceless')
  28      {
  29          parent::__construct(['body' => $body], [], $lineno, $tag);
  30      }
  31  
  32      public function compile(Compiler $compiler)
  33      {
  34          $compiler
  35              ->addDebugInfo($this)
  36          ;
  37          if ($compiler->getEnvironment()->isDebug()) {
  38              $compiler->write("ob_start();\n");
  39          } else {
  40              $compiler->write("ob_start(function () { return ''; });\n");
  41          }
  42          $compiler
  43              ->subcompile($this->getNode('body'))
  44              ->write("echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));\n")
  45          ;
  46      }
  47  }
  48  
  49  class_alias('Twig\Node\SpacelessNode', 'Twig_Node_Spaceless');


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1