本文整理汇总了PHP中Nette\Application\UI\Presenter::createTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::createTemplate方法的具体用法?PHP Presenter::createTemplate怎么用?PHP Presenter::createTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::createTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTemplate
/**
* @param string $class
* @return \Nette\Templating\ITemplate
*/
protected function createTemplate($class = NULL)
{
/** @var \Nette\Templating\FileTemplate|\stdClass $template */
$template = parent::createTemplate($class);
$template->registerHelperLoader(callback($this->presenter->context->getByType('Ale\\TemplateHelpers'), "loader"));
return $template;
}
示例2: createTemplate
/**
* @param null $class
* @return \Nette\Templating\ITemplate
*/
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$template->setTranslator($this->translator);
$template->registerHelperLoader(callback($this->helpers, 'loader'));
return $template;
}
示例3: createTemplate
/**
* @return \Nette\Bridges\ApplicationLatte\Template
*/
protected function createTemplate()
{
/** @var \Nette\Bridges\ApplicationLatte\Template $template */
$template = parent::createTemplate();
$this->latteFilters->install($template->getLatte());
return $template;
}
示例4: createTemplate
/**
*
*
* @param null $class
*
* @return mixed
*/
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$template->addFilter('format', function ($number) {
return number_format($number, 0, ',', ' ');
});
return $template;
}
示例5: createTemplate
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate();
$latte = $template->getLatte();
$set = new \Latte\Macros\MacroSet($latte->getCompiler());
$set->addMacro('scache', '?>?<?php echo strtotime(date(\'Y-m-d hh \')); ?>"<?php');
$latte->addFilter('scache', $set);
return $template;
}
示例6: createTemplate
/**
* @param string $class
* @return \Nette\Templating\ITemplate
*/
protected function createTemplate($class = NULL)
{
/** @var \Nette\Templating\FileTemplate|\stdClass $template */
$template = parent::createTemplate($class);
$template->registerHelper('mtime', function ($f) {
return $f . '?v=' . filemtime($this->context->parameters['wwwDir'] . '/' . $f);
});
return $template;
}
示例7: createTemplate
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$template->addFilter(NULL, '\\Filters::common');
// Add mobile detect and its helper to template
$template->_mobileDetect = $this->mobileDetect;
$template->_deviceView = $this->deviceView;
return $template;
}
示例8: createTemplate
/**
* @param string|NULL
* @return \Nette\Templating\ITemplate
*/
public function createTemplate($class = NULL)
{
$template = parent::createTemplate();
$template->registerHelperLoader($this->helperLoader);
if (isset($this->context->getParameters()['googleAnalyticsCode'])) {
$template->googleAnalyticsCode = $this->context->getParameters()['googleAnalyticsCode'];
}
return $template;
}
示例9: createTemplate
/**
* @return UI\ITemplate
*/
protected function createTemplate()
{
/** @var Nette\Bridges\ApplicationLatte\Template $template */
$template = parent::createTemplate();
$latte = $template->getLatte();
$latte->addFilter('texy', function ($input) {
$texy = $this->prepareTexy();
$html = new Nette\Utils\Html();
return $html::el()->setHtml($texy->process($input));
});
$latte->addFilter('vlna', function ($string) {
$string = preg_replace('<([^a-zA-Z0-9])([ksvzaiou])\\s([a-zA-Z0-9]{1,})>i', "\$1\$2 \$3", $string);
// === \xc2\xa0
return $string;
});
$latte->addFilter('dateInWords', function ($time) {
$time = Nette\Utils\DateTime::from($time);
$months = [1 => 'leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'];
return $time->format('j. ') . $months[$time->format('n')] . $time->format(' Y');
});
$latte->addFilter('timeAgoInWords', function ($time) {
$time = Nette\Utils\DateTime::from($time);
$delta = round((time() - $time->getTimestamp()) / 60);
if ($delta == 0) {
return 'před okamžikem';
}
if ($delta == 1) {
return 'před minutou';
}
if ($delta < 45) {
return "před {$delta} minutami";
}
if ($delta < 90) {
return 'před hodinou';
}
if ($delta < 1440) {
return 'před ' . round($delta / 60) . ' hodinami';
}
if ($delta < 2880) {
return 'včera';
}
if ($delta < 43200) {
return 'před ' . round($delta / 1440) . ' dny';
}
if ($delta < 86400) {
return 'před měsícem';
}
if ($delta < 525960) {
return 'před ' . round($delta / 43200) . ' měsíci';
}
if ($delta < 1051920) {
return 'před rokem';
}
return 'před ' . round($delta / 525960) . ' lety';
});
return $template;
}
示例10: createTemplate
/**
* @param string|NULL
* @return \Nette\Templating\ITemplate
*/
public function createTemplate($class = NULL)
{
/** @var \Nette\Bridges\ApplicationLatte\Template $template */
$template = parent::createTemplate();
$this->helperLoader->load($template->getLatte());
if (isset($this->context->getParameters()['googleAnalyticsCode'])) {
$template->googleAnalyticsCode = $this->context->getParameters()['googleAnalyticsCode'];
}
return $template;
}
示例11: createTemplate
/**
* @return Template
* @throws InvalidStateException
*/
protected function createTemplate()
{
/** @var Template $template */
$template = parent::createTemplate();
if ($this->helpers === NULL) {
throw new InvalidStateException('Please register presenter in config as Service, for autowiring dependencies!, ' . $this->getReflection()->getName());
}
$template->getLatte()->addFilter('base', callback($this->helpers, 'loader'));
return $template;
}
示例12: createTemplate
/**
* @return ITemplate
*/
protected function createTemplate()
{
$template = parent::createTemplate();
if ($template instanceof Template) {
$template->setTranslator($this->translator);
$template->addFilter(null, function ($filter, ...$args) {
if (method_exists($this->templateFilters, $filter)) {
return $this->templateFilters->{$filter}(...$args);
}
return null;
});
}
return $template;
}
示例13: createTemplate
public function createTemplate($class = NULL)
{
// pokud není nastaven, použijeme defaultní z configu
if (!isset($this->lang)) {
$this->lang = $this->context->parameters["lang"];
}
if ($this->lang == "cs") {
setlocale(LC_ALL, 'cs_CZ.UTF-8');
}
$template = parent::createTemplate($class);
$template->setTranslator($this->translator);
$helpers = $this->context->myTemplateHelpers;
$template->registerHelperLoader(array($helpers, 'loader'));
$template->lang = $this->lang;
return $template;
}
示例14: createTemplate
/**
*
* @param string|NULL $class
* @return Nette\Application\UI\ITemplate
*/
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$template->_gravatar = $this->gravatar;
$this->translator->createTemplateHelpers()->register($template->getLatte());
return $template;
}
示例15: createTemplate
/**
* Adds new helpers into the templates
* {@inheritdoc}
*/
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$template->registerHelperLoader('Helpers::loader');
return $template;
}