Пример #1
0
 public function optimize(Renderer $renderer, Filter $node, $options)
 {
     $inserts = array();
     $content = '';
     foreach ($node->getChilds() as $child) {
         foreach ($child->getContent()->getChilds() as $item) {
             if ($item instanceof Text) {
                 $content .= $item->getContent();
             } else {
                 $hash = md5(mt_rand());
                 $inserts[$hash] = $item;
                 $content .= $hash;
             }
         }
         $content .= "\n";
     }
     $string = new InterpolatedString(array());
     $result = $this->filter($content, array(), array());
     foreach ($inserts as $hash => $insert) {
         $parts = explode($hash, $result, 2);
         $string->addChild(new Text(array(), $parts[0]));
         $string->addChild($insert);
         $result = $parts[1];
     }
     $string->addChild(new Text(array(), $result));
     $string->accept($renderer);
 }
Пример #2
0
 public function optimize(Renderer $renderer, Filter $node, $options)
 {
     foreach ($node->getChilds() as $line) {
         $content = '';
         foreach ($line->getContent()->getChilds() as $child) {
             $content .= $child->getContent();
         }
         $renderer->write($content);
     }
 }
Пример #3
0
 protected function getContent(Filter $node)
 {
     $content = '';
     foreach ($node->getChilds() as $line) {
         foreach ($line->getContent()->getChilds() as $child) {
             $content .= $child->getContent();
         }
         $content .= "\n";
     }
     return $content;
 }