Skip to content
Permalink
Browse files

Template divided into hierarchy Template > DefaultTemplate

  • Loading branch information
dg committed Mar 4, 2020
1 parent dad3fd0 commit 888779125be4a7c27940f1f85b8c4d92e9c580e7
@@ -114,7 +114,7 @@ public function run(Application\Request $request): Application\IResponse
public function createTemplate(string $class = null, callable $latteFactory = null): Application\UI\ITemplate
{
$latte = $latteFactory ? $latteFactory() : $this->getContext()->getByType(Nette\Bridges\ApplicationLatte\ILatteFactory::class)->create();
$template = $class ? new $class : new Nette\Bridges\ApplicationLatte\Template($latte);
$template = $class ? new $class : new Nette\Bridges\ApplicationLatte\DefaultTemplate($latte);

$template->setParameters($this->request->getParameters());
$template->presenter = $this;
@@ -15,7 +15,7 @@
/**
* Control is renderable Presenter component.
*
* @property-read ITemplate|Nette\Bridges\ApplicationLatte\Template|\stdClass $template
* @property-read ITemplate|Nette\Bridges\ApplicationLatte\DefaultTemplate|\stdClass $template
*/
abstract class Control extends Component implements IRenderable
{
@@ -0,0 +1,18 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

namespace Nette\Bridges\ApplicationLatte;


/**
* Default template for controls and presenters.
*/
final class DefaultTemplate extends Template
{
}
@@ -50,7 +50,7 @@ public function __construct(ILatteFactory $latteFactory, Nette\Http\IRequest $ht
if ($templateClass && (!class_exists($templateClass) || !is_a($templateClass, Template::class, true))) {
throw new Nette\InvalidArgumentException("Class $templateClass does not extend " . Template::class . ' or it does not exist.');
}
$this->templateClass = $templateClass ?: Template::class;
$this->templateClass = $templateClass ?: DefaultTemplate::class;
}


0 comments on commit 8887791

Please sign in to comment.
You can’t perform that action at this time.