From 63982c428840093179e4a20c236b1cb90b9b4193 Mon Sep 17 00:00:00 2001 From: Chris Seufert Date: Thu, 18 Apr 2024 10:12:32 +1000 Subject: [PATCH] simpler handling for |with $ as name --- php/hamle/Tag/Control.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/php/hamle/Tag/Control.php b/php/hamle/Tag/Control.php index 6906385..6c5b2b2 100644 --- a/php/hamle/Tag/Control.php +++ b/php/hamle/Tag/Control.php @@ -106,19 +106,11 @@ function renderStTag(): string 'With requires a parameter for what to include', ); } + $out .= "\$scope = \$scope->withModel({$this->o} = {$hsv->toPHP()});\n"; if ($scopeName) { - $out .= - '$scope = $scope->withModel(' . - $hsv->toPHP() . - "); \$scope->setNamedModel(\"$scopeName\")\n;"; - } else { - $out .= - "if(({$this->o} = " . - $hsv->toPHP() . - ') && ' . - "{$this->o}->valid()) {\n"; - $out .= "\$scope = \$scope->withModel({$this->o});\n;"; + $out .= "\$scope->setNamedModel(\"$scopeName\");\n"; } + $out .= "if({$this->o}->valid()) {\n"; break; case 'include': if (!$hsv) { @@ -155,10 +147,8 @@ function renderEnTag(): string $out .= '}'; break; case 'with': - if (!preg_match('/ as ([a-zA-Z]+)$/', $this->var, $m)) { - $out .= '$scope = $scope->lastScope(); '; - $out .= '}'; - } + $out .= "}\n"; + $out .= "\$scope = \$scope->lastScope();\n"; break; case 'include': return '';