Ejemplo n.º 1
0
 /**
  * Replace <ktml:template:[format]></ktml:template:[format]> and rendered the content
  *
  * @param string $text  The text to parse
  * @param TemplateInterface $template A template object.
  * @return void
  */
 public function filter(&$text, TemplateInterface $template)
 {
     $factory = $this->getObject('template.engine.factory');
     $types = $factory->getFileTypes();
     $types = implode('|', $types);
     $matches = array();
     if (preg_match_all('#<ktml:template:(' . $types . ')>(.*)<\\/ktml:template:(' . $types . ')>#siU', $text, $matches)) {
         foreach ($matches[0] as $key => $match) {
             $data = $template->getData();
             $html = $factory->createEngine($matches[1][$key], array('functions' => $template->getFunctions()))->render($matches[2][$key], $data);
             $text = str_replace($match, $html, $text);
         }
     }
 }