public function should_display_correct_block_depth_level() { $h2o = new h2o('blog', $this->option); expects($h2o->render())->should_be('depth: 1'); $h2o->loadTemplate('home'); expects($h2o->render())->should_match('/depth: 2/'); }
/** * Render template with variables for sending in an email * * @param $template * @param $page * @return string */ static function renderEmail($template, $page) { // H2o object for rendering $h2o = new h2o(null, array('autoescape' => false)); // Load template and render it $h2o->loadTemplate(__DIR__ . '/../views/' . $template); return $h2o->render(compact('page')); }
/** * Handles rendering the header, footer, content and initialising the page * * @param $parameters * @return string */ function superHandler($parameters) { // Set our controller and view directories $controllerDirectory = __DIR__ . '/../controllers/'; $viewDirectory = __DIR__ . '/../views/'; // Initialise our page array $page = Session::init($parameters['title'], $parameters['flashes'], $parameters['restricted']); // if parameters are passed, then add them if (array_key_exists('parameters', $parameters)) { $page['parameters'] = $parameters['parameters']; } // Require our controller require $controllerDirectory . $parameters['controller']; // Initialise our h2o object $h2o = new h2o(null, array('autoescape' => false)); $output = ""; if (array_key_exists('header', $parameters) && $parameters['header'] == true) { $h2o->loadTemplate($viewDirectory . 'global/header.html'); $output .= $h2o->render(compact('page')); } if ($parameters['view'] != null) { $h2o->loadTemplate($viewDirectory . $parameters['view']); $output .= $h2o->render(compact('page')); } if (array_key_exists('footer', $parameters) && $parameters['footer'] == true) { $h2o->loadTemplate($viewDirectory . 'global/footer.html'); $output .= $h2o->render(compact('page')); } // return output return $output; }
require 'vendor/autoload.php'; /** * Let the provisioner automatically intervene and reconfigure Apache. This only * happens when users try to access a domain that Apache isn't aware off yet and * the provisioner will then - just in time - install vhost files and reload. */ \LXC\VirtualHost\ApacheProvisioner::check('root', 'root', 'templates/rebuilding.html', 'templates/vhost.conf'); /** * Configure the router. */ $router = new \Bramus\Router\Router(); $t = new \h2o(); # ROUTE /: index listing. $router->get('/', function () use($t) { $t->loadTemplate('templates/listing.html'); print $t->render(array('lxc' => \LXC\Container\Variables::get(), 'vhosts' => \LXC\VirtualHost\Listing::get(), 'hostsoutdated' => \LXC\VirtualHost\Listing::are_hosts_outdated(), 'logfiles' => \LXC\Logging\Files::get(), 'hostname' => gethostname())); }); # ROUTE /php: PHP information. $router->get('/php', function () { phpinfo(); }); # ROUTE /$LOGFILE: tail -f style log viewer. foreach (\LXC\Logging\Files::get() as $logfile) { $path = '/' . $logfile->name; $router->get($path, function () use($t, $logfile) { $t->loadTemplate('templates/logtail.html'); print $t->render(array('file' => $logfile, 'lxc' => \LXC\Container\Variables::get(), 'hostname' => gethostname())); }); $router->get($path . '/(\\d+)', function ($from_line) use($t, $logfile) { $logfile->sendPayload((int) $from_line);