Compare commits
10 Commits
b4b14fc38b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9719965abb | |||
| 4ce08f2ae4 | |||
| f6b21d80d4 | |||
| 2d1416ddf9 | |||
| 1bc25e2b70 | |||
| 6d7bab5bfe | |||
| a156637df8 | |||
| dd20215d6a | |||
| 8900d0bae6 | |||
| a262b71333 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,8 +1,4 @@
|
|||||||
# ---> Composer
|
composer.lock
|
||||||
composer.phar
|
composer.phar
|
||||||
/vendor/
|
/nbproject/
|
||||||
|
/vendor/
|
||||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
|
||||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
|
||||||
# composer.lock
|
|
||||||
|
|
||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 Potter
|
Copyright (c) 2025 Jay Potter
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||||
|
|||||||
22
composer.json
Normal file
22
composer.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "potter/template",
|
||||||
|
"type": "library",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.4",
|
||||||
|
"league/plates": "v3.x-dev",
|
||||||
|
"potter/aware": "dev-main"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Potter\\Template\\": "src/Potter/Template/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jay Potter",
|
||||||
|
"email": "j@ypotter.ca"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum-stability": "dev"
|
||||||
|
}
|
||||||
12
src/Potter/Template/Engine/AbstractTemplateEngine.php
Normal file
12
src/Potter/Template/Engine/AbstractTemplateEngine.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Template\Engine;
|
||||||
|
|
||||||
|
use \League\Plates\Engine;
|
||||||
|
|
||||||
|
abstract class AbstractTemplateEngine extends Engine implements TemplateEngineInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Template\Engine\Aware;
|
||||||
|
|
||||||
|
use \Potter\Aware\AwareInterface;
|
||||||
|
use \Potter\Template\Engine\TemplateEngineInterface;
|
||||||
|
|
||||||
|
interface TemplateEngineAwareInterface extends AwareInterface
|
||||||
|
{
|
||||||
|
public function getTemplateEngine(): TemplateEngineInterface;
|
||||||
|
public function hasTemplateEngine(): bool;
|
||||||
|
public function withTemplateEngine(): self;
|
||||||
|
public function withoutTemplateEngine(): self;
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Template\Engine\Aware;
|
||||||
|
|
||||||
|
use \Potter\Aware\AwareInterface;
|
||||||
|
use \Potter\Template\Engine\TemplateEngineInterface;
|
||||||
|
|
||||||
|
trait TemplateEngineAwareTrait
|
||||||
|
{
|
||||||
|
private const string TEMPLATE_ENGINE = 'templateEngine';
|
||||||
|
|
||||||
|
abstract public function get(string $key): mixed;
|
||||||
|
|
||||||
|
final public function getTemplateEngine(): TemplateEngineInterface
|
||||||
|
{
|
||||||
|
return $this->get(self::TEMPLATE_ENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function has(string $key): bool;
|
||||||
|
|
||||||
|
final public function hasTemplateEngine(): bool
|
||||||
|
{
|
||||||
|
return $this->has(self::TEMPLATE_ENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function set(string $key, mixed $value): mixed;
|
||||||
|
|
||||||
|
final public function setTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineInterface
|
||||||
|
{
|
||||||
|
return $this->set(self::TEMPLATE_ENGINE, $templateEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function unset(string $key): void;
|
||||||
|
|
||||||
|
final public function unsetTemplateEngine(): void
|
||||||
|
{
|
||||||
|
$this->unset(self::TEMPLATE_ENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function with(string $key, mixed $value): AwareInterface;
|
||||||
|
|
||||||
|
final public function withTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineAwareInterface
|
||||||
|
{
|
||||||
|
return $this->with(self::TEMPLATE_ENGINE, $templateEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function without(string $key): AwareInterface;
|
||||||
|
|
||||||
|
final public function withoutTemplateEngine(): TemplateEngineAwareInterface
|
||||||
|
{
|
||||||
|
return $this->without(self::TEMPLATE_ENGINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/Potter/Template/Engine/TemplateEngine.php
Normal file
10
src/Potter/Template/Engine/TemplateEngine.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Template\Engine;
|
||||||
|
|
||||||
|
final class TemplateEngine extends AbstractTemplateEngine
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
10
src/Potter/Template/Engine/TemplateEngineInterface.php
Normal file
10
src/Potter/Template/Engine/TemplateEngineInterface.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Template\Engine;
|
||||||
|
|
||||||
|
interface TemplateEngineInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user