public function createTemplate(Nette\Application\UI\Control $control) { $template = $this->templateFactory->createTemplate($control); $latte = $template->getLatte(); $latte->addFilter(null, [$this->templateHelpers, 'loader']); return $template; }
/** * @param string $template file * @param TemplateFactory $tf Template Factory - is needed! * @throws InvalidArgumentException Thrown when parameter combination does not match * @throws FileNotFoundException Thrown when path to the file is nonexistent or the file is not readable */ public function __construct($template, TemplateFactory $tf) { $this->template = NULL; if (is_string($template) && !file_exists($template) && file_exists(__DIR__ . '/' . $template)) { $template = __DIR__ . '/' . $template; } // Check & init if (!file_exists($template)) { throw new InvalidArgumentException('$template has to be either path to template or instance of \\Nette\\Templating\\ITemplate'); } $this->template = $tf->createTemplate(); $this->template->setFile($template); }
/** * * @param \Nette\Application\UI\Control $control * @return \Nette\Bridges\ApplicationLatte\Template */ public function createTemplate(UI\Control $control = NULL) { $template = parent::createTemplate($control); foreach ($this->defaults as $name => $value) { $template->{$name} = $value; } return $template; }
public function createTemplate(Control $control = NULL) { if ($control === NULL) { $control = $this->application->presenter; } $template = $this->templateFactory->createTemplate($control); $template->_imagePipe = $this->imagePipe; $template->locale = isset($control->getPresenter()->locale) ? $control->getPresenter()->locale : NULL; $template->addFilter('file', function ($path) { return $this->imagePipe->getPath() . '/' . $path; }); $template->addFilter('mangleEmail', function ($mail) { $parts = str_split($mail); $str = ''; foreach ($parts as $item) { $str .= '&#' . ord($item) . ";"; } return $str; }); return $template; }
/** * @param Control|null $control * @return Template */ public function createTemplate(Control $control = null) : Template { $template = parent::createTemplate($control); $latte = $template->getLatte(); foreach ([$this->tagHelpers, $this->datetimeHelpers] as $service) { $latte->addFilter(null, function ($name) use($service, $latte) { if ($callback = $service->loader($name)) { $latte->addFilter($name, $callback); } }); } $template->consts = $this->systemConstantsProvider; return $template; }
public function createTemplate(Nette\Application\UI\Control $control) { $template = parent::createTemplate($control); $translator = $this->translator; if ($control instanceof Zax\Application\UI\Control || $control instanceof Zax\Application\UI\Presenter) { $template->setTranslator($translator = $control->getTranslator()); $template->currentLocale = $control->getLocale(); $template->availableLocales = $control->getAvailableLocales(); } if ($control instanceof Zax\Application\UI\Control) { $template->ajaxEnabled = $control->isAjaxEnabled(); $template->view = $control->view; } $helpers = $this->createTemplateHelpers($translator); $template->getLatte()->addFilter(NULL, [$helpers, 'loader']); $template->icons = $this->icons; (new Zax\Html\Icons\LatteIcons($this->icons))->install($template->getLatte()); return $template; }
public function __construct(TemplateFactory $templateFactory) { $this->template = $templateFactory->createTemplate(new FakeControl()); $this->temp = dirname($this->template->getLatte()->getCacheFile('foo')); }
/** * @param UI\Control $control */ public function createTemplate(UI\Control $control = NULL) { $template = parent::createTemplate($control); return $template; }
/** * @return Template */ public function createTemplate(UI\Control $control = null) { $template = parent::createTemplate($control); $template->authorizator = $this->authorizator; return $template; }
/** * Template factory * * @param Control $control * @return Template */ public function createTemplate(Control $control = NULL) { $template = parent::createTemplate($control); $template->setTranslator($this->getTranslator()); return $template; }