コード例 #1
0
ファイル: NpMacros.php プロジェクト: osmcz/website
 function processTemplateMacro($macro, $file, $optstr)
 {
     $template = new FileTemplate($file);
     $template->registerFilter(Environment::getNette()->createLatte());
     $template->registerHelperLoader('TemplateHelpers::loader');
     $template->setCacheStorage(Environment::getContext()->nette->templateCacheStorage);
     $template->page = $this->pageContext;
     //TODO disable macros in getContent()
     $template->opts = $opts = self::parseOptions($optstr);
     //from Nette\Application\UI\Control
     $template->baseUri = $template->baseUrl = rtrim($this->url->getBaseUrl(), '/');
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     //lang settings
     $template->lang = $this->pageContext->lang;
     $template->langs = $this->i18n->langs;
     $template->setTranslator(new TranslationsModel($this->pageContext->lang));
     try {
         $template = $template->__toString(true);
     } catch (Exception $e) {
         if (Debugger::$productionMode) {
             Debugger::log($e);
             return "<span class='zprava'>Error: {$macro} not availible</span>";
         } else {
             return "<span class='zprava'>Error: " . $e->getMessage() . "</span>";
         }
     }
     return $template;
 }