Esempio n. 1
0
 private static function renderTemplateAsync(Template $tpl)
 {
     $partial = $tpl->__toString();
     // render, but component will provide only placeholders
     $ret = Flow::run(self::$components);
     $html = preg_replace_callback('/\\x01(\\d+)\\x02/', function ($m) use($ret) {
         return $ret[$m[1]];
     }, $partial);
     return $html;
 }
Esempio n. 2
0
 private function _avelancheTransform($text, $filterParams = NULL, $templateParams = NULL)
 {
     //dump($filterParams);
     $_temp = $text;
     $hash = NULL;
     $oldHash = NULL;
     for ($i = 1; $i <= 50; $i++) {
         $template = new \Nette\Templating\Template();
         $template->setTranslator($this->presenter->context->translator);
         $template->setSource($_temp);
         $template->add('_presenter', $this->presenter);
         $template->add('_control', $this->presenter);
         $template->add('_page', $this);
         if ($templateParams !== NULL) {
             foreach ($templateParams as $k => $v) {
                 $template->add($k, $v);
             }
         }
         $template->onPrepareFilters[] = function ($template) use($filterParams) {
             $template->registerFilter(new Bubo\Filters\CMSFilter($filterParams));
         };
         $template->onPrepareFilters[] = function ($template) {
             $template->registerFilter(new \Nette\Latte\Engine());
         };
         //$template->setCacheStorage(new \Nette\Caching\Storages\PhpFileStorage(TEMP_DIR.'/cache'));
         $_temp = $template->__toString();
         if (($hash = sha1($_temp)) == $oldHash) {
             break;
         }
         $oldHash = $hash;
     }
     return $_temp;
 }