/** * Render the template, returning it's content. */ public function render($template, $variables = []) { extract($variables); ob_start(); include views_path() . '/' . $template . '.php'; return ob_end_flush(); }
public static function getCirclesFromView($view_name, $data) { // read view file content $handled_view = file_get_contents(views_path($view_name . '.alien.php')) . "\n"; // show $data to view $handled_view = static::getViewWithData($handled_view, $data); // split the view by circle blocks preg_match_all(static::$template_regex['circle']['regex'], $handled_view, $circles); $c = []; foreach ($circles['name'] as $key => $name) { $c[$name] = $circles['body'][$key]; } // return the circles of view in array return $c; }
/** * Get a Twig instance * @return Twig_Environment Twig environment */ function twig() { $directory = new RecursiveDirectoryIterator(views_path()); $iterator = new RecursiveIteratorIterator($directory); $regex = new RegexIterator($iterator, '/^.+\\.twig$/i', RecursiveRegexIterator::GET_MATCH); $tpl_files = []; foreach ($regex as $file) { $tpl_files[str_replace([views_path() . DIRECTORY_SEPARATOR, '.twig', DIRECTORY_SEPARATOR], ['', '', '.'], $file[0])] = file_get_contents($file[0]); } $loader = new Twig_Loader_Array($tpl_files); $twig = new Twig_Environment($loader); /** * Load Twig extensions */ $twig->addExtension(new Twig_Extensions_Extension_Text()); $route_function = new Twig_SimpleFunction('route', function () { return '/'; }); $twig->addFunction($route_function); return $twig; }
public function __construct() { $views = views_path(); $cache = cache_path(''); $this->blade = new BladeEngine($views, $cache); }
<title>Social.net</title> <link rel="stylesheet" href="/assets/css/styles.css"> </head> <body class="dark"> <div class="background"></div> <?php include views_path() . '/partials/header.php'; ?> <div class="container"> <div class="auth"> <div class="col"> <?php include views_path() . '/partials/login.php'; ?> </div> <div class="separator"></div> <div class="col"> <?php include views_path() . '/partials/registration.php'; ?> </div> </div> </div> <?php include views_path() . '/partials/flash.php'; include views_path() . '/partials/footer.php'; ?> <script src="/assets/js/app.js"></script> </body> </html>
public function register($app) { $app->add('Twig_Environment')->withArgument(new \Twig_Loader_Filesystem(views_path())); }