Skip to content

Commit

Permalink
simpler handling for |with $ as name
Browse files Browse the repository at this point in the history
  • Loading branch information
cseufert committed Apr 18, 2024
1 parent d39034d commit 63982c4
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions php/hamle/Tag/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 '';
Expand Down

0 comments on commit 63982c4

Please sign in to comment.