Ejemplo n.º 1
0
 protected function createTemplate()
 {
     $template = new FileTemplate();
     $filter = new LatteFilter();
     $template->registerFilter($filter);
     return $template;
 }
Ejemplo n.º 2
0
	/**
	 * @return Nette\Templates\ITemplate
	 */
	protected function createTemplate()
	{
		$template = new Nette\Templates\FileTemplate;
		$presenter = $this->getPresenter(FALSE);
		$template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');

		// default parameters
		$template->control = $this;
		$template->presenter = $presenter;
		$template->user = Nette\Environment::getUser();
		$template->baseUri = rtrim(Nette\Environment::getVariable('baseUri', NULL), '/');
		$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUri);

		// flash message
		if ($presenter !== NULL && $presenter->hasFlashSession()) {
			$id = $this->getParamId('flash');
			$template->flashes = $presenter->getFlashSession()->$id;
		}
		if (!isset($template->flashes) || !is_array($template->flashes)) {
			$template->flashes = array();
		}

		// default helpers
		$template->registerHelper('escape', 'Nette\Templates\TemplateHelpers::escapeHtml');
		$template->registerHelper('escapeUrl', 'rawurlencode');
		$template->registerHelper('stripTags', 'strip_tags');
		$template->registerHelper('nl2br', 'nl2br');
		$template->registerHelper('substr', 'iconv_substr');
		$template->registerHelper('repeat', 'str_repeat');
		$template->registerHelper('replaceRE', 'Nette\String::replace');
		$template->registerHelper('implode', 'implode');
		$template->registerHelper('number', 'number_format');
		$template->registerHelperLoader('Nette\Templates\TemplateHelpers::loader');

		return $template;
	}
Ejemplo n.º 3
0
 protected function createTemplate($file = null)
 {
     $template = new FileTemplate();
     $template->setFile($file);
     $template->registerHelperLoader("Nette\\Templates\\TemplateHelpers::loader");
     $template->registerHelper('substr', 'substr');
     $filter = new LatteFilter();
     $template->registerFilter($filter);
     return $template;
 }
Ejemplo n.º 4
0
	/**
	 * Creates and returns configured template.
	 *
	 * @author   Jan Tvrdík, David Grudl
	 * @param    string            template file path
	 * @return   Nette\Templates\FileTemplate
	 */
	protected function createTemplate($path = NULL)
	{
		$template = new Nette\Templates\FileTemplate($path);

		// default parameters
		$template->baseUri = rtrim(Env::getVariable('baseUri', NULL), '/');
		$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUri);
		$template->presenter = $this;
		$template->page = $this->page;
		$template->lang = $this->lang;

		// default filters
		$template->onPrepareFilters[] = function($template) {
			require_once APP_DIR . '/classes/ConfiguredTexy.php';
			require_once APP_DIR . '/classes/TexyElementsFilter.php';
			require_once APP_DIR . '/classes/LatteMacros.php';

			$texyElementsFilter = new TexyElementsFilter();
			$texyElementsFilter->texy = new ConfiguredTexy();
			$texyElementsFilter->autoChangeSyntax = TRUE;

			$latteHandler = new LatteMacros();
			$latteHandler->macros['@href'] = ' href="<?php echo %:escape%(%:macroPageLink%) ?>"';
			$latteFilter = new Nette\Templates\LatteFilter();
			$latteFilter->setHandler($latteHandler);

			$template->registerFilter($texyElementsFilter);
			$template->registerFilter($latteFilter);
		};

		// default helpers
		$template->registerHelper('escape', 'Nette\Templates\TemplateHelpers::escapeHtml');
		$template->registerHelper('escapeUrl', 'rawurlencode');
		$template->registerHelper('stripTags', 'strip_tags');
		$template->registerHelper('nl2br', 'nl2br');
		$template->registerHelper('substr', 'iconv_substr');
		$template->registerHelper('repeat', 'str_repeat');
		$template->registerHelper('replaceRE', 'Nette\String::replace');
		$template->registerHelper('implode', 'implode');
		$template->registerHelper('number', 'number_format');
		$template->registerHelperLoader('Nette\Templates\TemplateHelpers::loader');

		return $template;
	}
Ejemplo n.º 5
0
 /**
  * Template factory
  * @return Template
  */
 private function createTemplate()
 {
     $template = new FileTemplate();
     $template->registerFilter(new LatteFilter());
     return $template;
 }