- A lot of bugfixes made for this release.
This commit is contained in:
1 parent
4e909b2840
commit
8df38b568c
13 files changed
+159
-71
No files matched your search
@@ -29,7 +29,10 @@ class BlockToken implements ControlStructure {
|
||||
unset(\$inlineVariables);
|
||||
}
|
||||
catch(\TypeError \$ex) {
|
||||
throw new \Exception('A block awaiting arguments `$arguments` instead received `' . implode(', ', array_map('gettype', \$inlineVariables)) . '`');
|
||||
|
||||
throw new \Exception(
|
||||
sprintf('A block awaiting arguments `%s` instead received `%s` with values `%s`', '$arguments', implode(', ', array_map('gettype', \$inlineVariables)), json_encode(\$inlineVariables))
|
||||
);
|
||||
}
|
||||
?>
|
||||
PHP;
|
||||
|
||||
@@ -20,6 +20,10 @@ class ForToken implements ControlStructure {
|
||||
return "<?php for ($arguments): {$uid} = 1; ?>";
|
||||
|
||||
case "endfor":
|
||||
if ( $context->iterationStack === null ){
|
||||
|
||||
}
|
||||
|
||||
if ( end($context->iterationStack)['or'] === false ) {
|
||||
$output = "<?php endfor; ?>";
|
||||
}
|
||||
@@ -30,6 +34,9 @@ class ForToken implements ControlStructure {
|
||||
array_pop($context->iterationStack);
|
||||
|
||||
return $output;
|
||||
|
||||
case "continue":
|
||||
return "<?php continue; ?>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,13 @@ namespace Picea\ControlStructure;
|
||||
|
||||
class ForeachToken implements ControlStructure {
|
||||
|
||||
public array $token = [ "foreach", "endforeach" ];
|
||||
public array $token = [ "foreach", "endforeach", "continue" ];
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
|
||||
switch($token) {
|
||||
case "continue":
|
||||
return "<?php continue; ?>";
|
||||
|
||||
case "foreach":
|
||||
$name = "$".uniqid("foreach_");
|
||||
|
||||
@@ -27,7 +30,7 @@ class ForeachToken implements ControlStructure {
|
||||
'token' => 'endforeach',
|
||||
];
|
||||
|
||||
return "<?php foreach ($arguments): $name = ( $name ?? 0 ) + 1; ; ?>";
|
||||
return "<?php foreach ($arguments): $name = ( $name ?? 0 ) + 1; ?>";
|
||||
|
||||
case "endforeach":
|
||||
if ( end($context->iterationStack)['or'] === false ) {
|
||||
|
||||
@@ -47,13 +47,13 @@ class SectionToken implements ControlStructure {
|
||||
|
||||
return "<?php \$___class__template->sectionList[$name] ??= [ 'prepend' => [], 'append' => [], 'default' => [] ];".
|
||||
"\$___class__template->sectionList[$name]['$action'][] = [ 'order' => $order, 'callback' => function() use (\$picea, \$___class__template, \$___global_variables, \$___variables) {".
|
||||
"extract(\$___global_variables); extract(\$___variables, \EXTR_OVERWRITE); ?>";
|
||||
"extract(\$___global_variables); extract(\$___variables, \EXTR_OVERWRITE); \$___class__template->sectionStack[] = '$name'; ?>";
|
||||
}
|
||||
|
||||
protected function printEndSection($context) : string
|
||||
{
|
||||
$section = array_pop($context->sections);
|
||||
$build = $context->extendFrom ? "" : "\$___class__template->renderSection({$section['name']});";
|
||||
return "<?php }]; $build?>";
|
||||
$build = $context->extendFrom ? "\$___class__template->sectionStack && \$___class__template->renderSection({$section['name']});" : "\$___class__template->renderSection({$section['name']});";
|
||||
return "<?php array_pop(\$___class__template->sectionStack); }]; $build?>";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user