add Twig for template rendering
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Lexi / Zoe 2020-07-01 00:12:23 +02:00
parent 7cc2d40660
commit 92a4d2fcf8
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
7 changed files with 333 additions and 81 deletions

View file

@ -5,9 +5,13 @@ namespace NoteCat;
use DI\Container;
use Psr\Container\ContainerInterface;
use Slim\Views\Twig;
class Dependencies
{
private const TWIG = 'view';
private const TWIG_TEMPLATE_DIR = __DIR__ . '/../templates';
public static function createContainer(): Container
{
$container = new Container();
@ -15,6 +19,7 @@ class Dependencies
// Controllers
$container->set(HelloWorldController::class, function (ContainerInterface $c) {
return new HelloWorldController(
$c->get(self::TWIG),
$c->get(HelloWorld::class)
);
});
@ -24,6 +29,12 @@ class Dependencies
return new HelloWorld();
});
$container->set(self::TWIG, function (ContainerInterface $c) {
// TODO cache
$twigSettings = [];
return Twig::create(self::TWIG_TEMPLATE_DIR, $twigSettings);
});
return $container;
}
}