Compare commits
No commits in common. "ded3d5e9076ca946f199b07731060308fb50d060" and "84020a871c301314021d46a8c05c92b537e8056a" have entirely different histories.
ded3d5e907
...
84020a871c
@ -7,7 +7,7 @@ It also insert `Tell` inside the LanguageHandler which handles the `{% _ 'relati
|
|||||||
```php
|
```php
|
||||||
use function DI\autowire, DI\create, DI\get;
|
use function DI\autowire, DI\create, DI\get;
|
||||||
|
|
||||||
use Laminas\Diactoros\Response\HtmlResponse;
|
use Zend\Diactoros\Response\HtmlResponse;
|
||||||
|
|
||||||
use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request };
|
use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request };
|
||||||
use Picea\Extension\{ LanguageHandler, LanguageExtension, TitleExtension, MoneyExtension, UrlExtension };
|
use Picea\Extension\{ LanguageHandler, LanguageExtension, TitleExtension, MoneyExtension, UrlExtension };
|
||||||
|
@ -14,8 +14,6 @@ abstract class Context {
|
|||||||
|
|
||||||
public string $compiledSource = "";
|
public string $compiledSource = "";
|
||||||
|
|
||||||
public ? string $sectionAction = null;
|
|
||||||
|
|
||||||
public string $viewPath = "";
|
public string $viewPath = "";
|
||||||
|
|
||||||
public string $filePath = "";
|
public string $filePath = "";
|
||||||
|
@ -4,14 +4,10 @@ namespace Picea\ControlStructure;
|
|||||||
|
|
||||||
class SectionToken implements ControlStructure {
|
class SectionToken implements ControlStructure {
|
||||||
|
|
||||||
public array $token = [ "section", "section.prepend", "section.append", "endsection" ];
|
public array $token = [ "section", "endsection" ];
|
||||||
|
|
||||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) {
|
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) {
|
||||||
switch($token) {
|
switch($token) {
|
||||||
case "section.prepend":
|
|
||||||
$context->sectionAction = "prepend";
|
|
||||||
case "section.append":
|
|
||||||
$context->sectionAction ??= "append";
|
|
||||||
case "section":
|
case "section":
|
||||||
return $this->printSection($context, $arguments);
|
return $this->printSection($context, $arguments);
|
||||||
|
|
||||||
@ -32,7 +28,7 @@ class SectionToken implements ControlStructure {
|
|||||||
$options = eval("return $options;");
|
$options = eval("return $options;");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! ctype_alnum(str_replace([".", "\"", "'", "-", "_", ":"], "", $name)) ) {
|
if ( ! ctype_alnum(str_replace([".", "\"", "'", "-", "_"], "", $name)) ) {
|
||||||
throw new \RuntimeException("Your section named `{$name}` contains invalid character. Allowed are only letters, numbers, dashes, underscores and dots");
|
throw new \RuntimeException("Your section named `{$name}` contains invalid character. Allowed are only letters, numbers, dashes, underscores and dots");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +37,7 @@ class SectionToken implements ControlStructure {
|
|||||||
'options' => $options,
|
'options' => $options,
|
||||||
];
|
];
|
||||||
|
|
||||||
$action = $options['action'] ?? $context->sectionAction ?? "default";
|
$action = $options['action'] ?? "default";
|
||||||
|
|
||||||
unset($context->sectionAction);
|
|
||||||
|
|
||||||
if (! in_array($action, ['prepend', 'append', 'default'])) {
|
if (! in_array($action, ['prepend', 'append', 'default'])) {
|
||||||
throw new \RuntimeException("An unsupported action `$action` was given as an option of a {% section %} tag");
|
throw new \RuntimeException("An unsupported action `$action` was given as an option of a {% section %} tag");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user