From 33298ff2e47d88be905f5636c9eab4c3153a53d4 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Thu, 8 Dec 2022 19:10:43 +0000 Subject: [PATCH] - Removed optional brackets from routes in UrlExtension. --- src/Extension/UrlExtension.php | 10 ++++++++++ src/Picea.php | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Extension/UrlExtension.php b/src/Extension/UrlExtension.php index 2d92deb..b9ac50c 100644 --- a/src/Extension/UrlExtension.php +++ b/src/Extension/UrlExtension.php @@ -234,6 +234,16 @@ PATTERN; $route = str_replace(array_keys($search), array_values($search), $route); } + /* + * @TODO - must also take into account that recursivity is possible here [/test[/another[/still]]], + * so the regex must be adjusted (or simply using another method could also be a possiblity) + * while(strpos($route, '[') !== false && strpos($route, ']') !== false ) { + if ( preg_match_all('~[(.*?)]~si', $route, $matches, PREG_SET_ORDER) ) { + + } + }*/ + $route = trim(str_replace([ '[', ']' ], '', $route), '/'); + return $route; } } diff --git a/src/Picea.php b/src/Picea.php index 8ab24e6..3542036 100644 --- a/src/Picea.php +++ b/src/Picea.php @@ -69,11 +69,13 @@ class Picea implements LanguageRegistration public function renderHtml(string $viewPath, array $variables = [], ?object $proxy = null) : ? string { + $object = $this->gatherTemplateObject($viewPath, $variables, $proxy); + try { - return call_user_func($this->gatherTemplateObject($viewPath, $variables, $proxy)); + return call_user_func($object); } catch(\Throwable $ex) { - throw $ex; + #throw $ex; # Temporary class for an experiment on retrieving more accurate debug info throw new class($object, $this, "An error occurred trying to render HTML view `$viewPath` : " . $ex->getMessage(), 911, $ex) extends \Exception {