function createTemplate($class = NULL, callable $latteFactory = NULL)
	{
		$template = $this->getTemplateFactory()->createTemplate($this);

		// Macro {url ...}
		$latte = $template->getLatte();
		$macroSet = new Latte\Macros\MacroSet($latte->getCompiler());
		$macroSet->addMacro('url', function () {}/*, NULL, NULL, $macroSet::ALLOWED_IN_HEAD*/); // ignore

		$params = $this->request->getParameters();
		$template->presenter = $this;
		$template->context = $this->context;

		$file = self::actionToFilename($params['action']);
		if ($file{0} !== '/') {
			$file = $this->getPagesDir() . DIRECTORY_SEPARATOR . $file;
			if ( ! Strings::endsWith($file, '.latte')) {
				$file .= '.latte';
			}
		}

		$template->setFile($file);

		if ($this->getHttpRequest()) {
			$url = $this->getHttpRequest()->getUrl();
			$template->baseUrl = rtrim($url->getBaseUrl(), '/');
			$template->basePath = rtrim($url->getBasePath(), '/');
		}

		return $template;
	}