Skip to content

Commit 63982c4

Browse files
committed
simpler handling for |with $ as name
1 parent d39034d commit 63982c4

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

php/hamle/Tag/Control.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,11 @@ function renderStTag(): string
106106
'With requires a parameter for what to include',
107107
);
108108
}
109+
$out .= "\$scope = \$scope->withModel({$this->o} = {$hsv->toPHP()});\n";
109110
if ($scopeName) {
110-
$out .=
111-
'$scope = $scope->withModel(' .
112-
$hsv->toPHP() .
113-
"); \$scope->setNamedModel(\"$scopeName\")\n;";
114-
} else {
115-
$out .=
116-
"if(({$this->o} = " .
117-
$hsv->toPHP() .
118-
') && ' .
119-
"{$this->o}->valid()) {\n";
120-
$out .= "\$scope = \$scope->withModel({$this->o});\n;";
111+
$out .= "\$scope->setNamedModel(\"$scopeName\");\n";
121112
}
113+
$out .= "if({$this->o}->valid()) {\n";
122114
break;
123115
case 'include':
124116
if (!$hsv) {
@@ -155,10 +147,8 @@ function renderEnTag(): string
155147
$out .= '}';
156148
break;
157149
case 'with':
158-
if (!preg_match('/ as ([a-zA-Z]+)$/', $this->var, $m)) {
159-
$out .= '$scope = $scope->lastScope(); ';
160-
$out .= '}';
161-
}
150+
$out .= "}\n";
151+
$out .= "\$scope = \$scope->lastScope();\n";
162152
break;
163153
case 'include':
164154
return '';

0 commit comments

Comments
 (0)