- Added a new {% block ... %} token
- Added a new {% php ... %} token
- Fixed a bug with an OR if foreach is empty
This commit is contained in:
1 parent
0e201b77f2
commit
404d1f4359
9 files changed
+143
-22
No files matched your search
@@ -7,14 +7,20 @@ class ForeachToken implements ControlStructure {
|
||||
public string $token = "foreach";
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
|
||||
$uid = "$".uniqid("foreach_");
|
||||
$name = "$".uniqid("foreach_");
|
||||
|
||||
$count = count($context->iterationStack ?? []);
|
||||
|
||||
if ( $count > 0 ) {
|
||||
$name .= "[" . $context->iterationStack[$count - 1]['uid'] . "]";
|
||||
}
|
||||
|
||||
$context->iterationStack[] = [
|
||||
'or' => false,
|
||||
'uid' => $uid,
|
||||
'uid' => $name,
|
||||
'token' => 'endforeach',
|
||||
];
|
||||
|
||||
return "<?php foreach ($arguments): {$uid} = 1; ?>";
|
||||
|
||||
return "<?php foreach ($arguments): $name = ( $name ?? 0 ) + 1; ; ?>";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user