- Fixed 'title' method and extension
This commit is contained in:
1 parent
e8d81222ff
commit
2df950a054
2 files changed
+99
-3
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user