- Fixed 'title' method and extension

This commit is contained in:
Dave Mc Nicoll committed 2020-01-31 16:36:26 -05:00
1 parent e8d81222ff
commit 2df950a054
2 files changed
+99 -3

No files matched your search

+27 -3
View File
@@ -2,12 +2,36 @@
namespace Picea\Extension;
use Picea\Compiler\Context;
class TitleExtension implements Extension {
public string $token = "title";
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
return "<?php /* echo title ?? */ ?>";
public string $title = "";
public function __construct(Context $context) {
$this->register($context);
}
public function register(Context $context) : void
{
$context->pushFunction("title", [ $this, 'handleTitle' ]);
}
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
return "<?php echo title($arguments) ?>";
}
public function handleTitle(? string $set = null) : ? string
{
if ( $set === null ) {
return $this->title;
}
else {
$this->title = $set;
}
return null;
}
}