generated from inherelab/php-pkg-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: update some method sign for compiler class
- Loading branch information
Showing
18 changed files
with
250 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpPkg\EasyTpl\Extended; | ||
|
||
use Toolkit\Stdlib\Obj\Traits\AutoConfigTrait; | ||
|
||
class ExtendLoader | ||
{ | ||
use AutoConfigTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpPkg\EasyTpl\Extended; | ||
|
||
use PhpPkg\EasyTpl\Contract\CompilerInterface; | ||
use PhpPkg\EasyTpl\EasyTemplate; | ||
use function sprintf; | ||
use function trim; | ||
|
||
/** | ||
* Class ExtendedTemplate TODO | ||
* | ||
* @package PhpPkg\EasyTpl | ||
*/ | ||
class ExtendedTemplate extends EasyTemplate | ||
{ | ||
public const BLOCK_VAR_PREFIX = 'TPL_BLOCK_'; | ||
|
||
private $currentBlock = ''; | ||
|
||
protected function init(CompilerInterface $compiler): void | ||
{ | ||
parent::init($compiler); | ||
|
||
$compiler | ||
->addDirective('extend', function (string $tplName) { | ||
return ExtendLoader::new()->handle($tplName); | ||
}) | ||
->addDirective('extends', function () { | ||
|
||
}) | ||
->addDirective('block', function (string $body) { | ||
$this->currentBlock = trim($body, '() '); | ||
|
||
return sprintf('$this->startBlock(%s);', $this->currentBlock); | ||
}) | ||
->addDirective('endblock', function () { | ||
return '$this->endBlock();'; | ||
}); | ||
} | ||
|
||
protected function startBlock(string $name): void | ||
{ | ||
|
||
} | ||
|
||
protected function endBlock(): void | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpPkg\EasyTpl\Extended; | ||
|
||
use PhpPkg\EasyTpl\Contract\CompilerInterface; | ||
use PhpPkg\EasyTpl\EasyTemplate; | ||
|
||
/** | ||
* Class LayoutTemplate TODO | ||
* @package PhpPkg\EasyTpl\Extended | ||
*/ | ||
class LayoutTemplate extends EasyTemplate | ||
{ | ||
|
||
protected function init(CompilerInterface $compiler): void | ||
{ | ||
parent::init($compiler); | ||
|
||
$compiler | ||
->addDirective('layout', function (string $tplName) { | ||
return ExtendLoader::new()->handle(); | ||
}) | ||
->addDirective('contents', function () { | ||
return '$this->contents();'; | ||
}); | ||
} | ||
} |
Oops, something went wrong.