From 0bec263d783c76c309ea95029e37aff68437d983 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 29 Oct 2020 22:30:07 +0100 Subject: [PATCH] allow custom template extension --- Views/ViewAbstract.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 44d1fc0ec..ab27a7b36 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -58,15 +58,16 @@ abstract class ViewAbstract implements RenderableInterface /** * Set the template. * - * @param string $template View template + * @param string $template View template + * @param string $extension Extension of the template * * @return void * * @since 1.0.0 */ - public function setTemplate(string $template) : void + public function setTemplate(string $template, string $extension = 'tpl.php') : void { - $this->template = $template; + $this->template = __DIR__ . '/../..' . $template . '.' . $extension; } /** @@ -223,8 +224,7 @@ abstract class ViewAbstract implements RenderableInterface try { \ob_start(); - $path = __DIR__ . '/../..' . $this->template . '.tpl.php'; - + $path = $this->template; if (!\is_file($path)) { throw new PathException($path); }