コード例 #1
0
ファイル: TodoPanel.php プロジェクト: ped7g/TodoPanel
 /**
  * Renders HTML code for custom panel.
  * @return void
  */
 public function getPanel()
 {
     ob_start();
     $template = new Template(dirname(__FILE__) . '/bar.todo.panel.phtml');
     $template->registerFilter(new LatteFilter());
     $template->todos = $this->getTodo();
     $template->render();
     return $cache['output'] = ob_get_clean();
 }
コード例 #2
0
ファイル: Control.php プロジェクト: norbe/AutoUse
	/**
	 * @return Nette\Templates\ITemplate
	 */
	protected function createTemplate()
	{
		$template = new Nette\Templates\Template;
		$presenter = $this->getPresenter(FALSE);
		$template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');

		// default parameters
		$template->control = $this;
		$template->presenter = $presenter;
		$template->user = Nette\Environment::getUser();
		$template->baseUri = Nette\Environment::getVariable('baseUri', NULL);
		$template->basePath = rtrim($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;
	}