added session, moved twig, updated base

This commit is contained in:
2024-09-12 16:28:33 -07:00
parent f19f59d53a
commit 937e4581ba
3 changed files with 77 additions and 15 deletions

17
src/twig.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
//Twig
function view($name = '', $data = [] ) {
$loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
$loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
$loader->addPath(BASEPATH . '/App/templates', 'override');
$twig = new Twig\Environment($loader);
//check if file exists
if (file_exists(BASEPATH . '/App/views/' . $name . '.html.twig')) {
echo $twig->render("$name" . '.html.twig', $data);
return true;
} else {
echo "Error: Twig Template ($name) Not Found.";
return false;
}
}