Big Update Added Services and Admin
This commit is contained in:
16
src/twig.php
16
src/twig.php
@@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
//Twig
|
||||
function view($name = '', $data = []) {
|
||||
global $config; // Use the globally included $config
|
||||
function view($name = '', $moreData = []) {
|
||||
global $config, $data; // Use the globally included $config
|
||||
|
||||
if (!empty($moreData)){
|
||||
$data = array_merge($data, $moreData);
|
||||
}
|
||||
|
||||
$loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
|
||||
$loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
|
||||
$loader->addPath(FRAMEWORKPATH . '/twig', 'novaconium');
|
||||
$loader->addPath(FRAMEWORKPATH . '/views', 'novacore');
|
||||
$loader->addPath(BASEPATH . '/App/templates', 'override');
|
||||
|
||||
$twig = new Twig\Environment($loader);
|
||||
@@ -15,7 +20,10 @@ function view($name = '', $data = []) {
|
||||
|
||||
// Check if the template exists
|
||||
if (file_exists(BASEPATH . '/App/views/' . $name . '.html.twig')) {
|
||||
echo $twig->render("$name.html.twig", $data);
|
||||
echo $twig->render($name . '.html.twig', $data);
|
||||
return true;
|
||||
} elseif (str_starts_with($name, '@')) { // Check if using framework
|
||||
echo $twig->render($name . '.html.twig', $data);
|
||||
return true;
|
||||
} else {
|
||||
echo "Error: Twig Template ($name) Not Found.";
|
||||
|
||||
Reference in New Issue
Block a user