public function __invoke(array $input) { $name = 'index'; if (!empty($input['name'])) { $name = $input['name']; } // $filename = APPPATH . 'templates/static/' . $name; // if (file_exists($filename)) { // echo "The file $filename does not exist"; // die('the file does not exist'); // } // Create new Plates instance $plates = new Engine(APPPATH . 'templates'); // Register extension $plates->loadExtension(new Utils()); // Check static page or partial exists if ($plates->exists('static/' . $name)) { // Render a template $template = $plates->render('static/' . $name); } else { header("HTTP/1.0 404 Not Found"); echo "PHP continues.\n"; echo "Not after a die, however.\n"; die; } // return return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $template]); }
/** * Get Current Layout Name in Plates Template Engine style * If user have created a layout.php in the default folder, use their layout.php. * Or else use the default layout. * * @return string Layout Name */ private function getLayoutName() { if ($this->layout != null) { return $this->layout; } try { return $this->template->exists("backend_layout") ? "backend_layout" : $this->theme . "::layout"; } catch (\LogicException $ex) { return $this->theme . "::layout"; } }
/** * Returns whether or not the given template exists. * * @param string $template * * @return bool */ public function exists($template) { return $this->plates->exists($template); }
public function testCanRender() { $this->assertSame($this->engine->exists('does-not-exist'), $this->strategy->canRender('does-not-exist')); $this->assertSame($this->engine->exists('simple'), $this->strategy->canRender('simple')); }
/** * {@inheritDoc} */ public function canRender($template) { return $this->engine->exists($template); }