public function testSingleton() { $fixture = views\TemplateLoader::GetInstance(); $this->assertNotSame($fixture, $this->fixture); views\TemplateLoader::SetInstance($this->fixture); $this->assertSame(views\TemplateLoader::GetInstance(), $this->fixture); $template = views\TemplateLoader::Fetch('cache_test'); $this->assertEquals('This file should be cached.', $template->template()); }
static public function Import($template, $vars) { echo TemplateLoader::Fetch($template)->Render($vars); }
private function _CreateBodyForResponse(Request $request, Response $response) { $type = $response->context[self::OUTPUT_FILTER_TYPE]; if ($type == 'json') { $response->headers['Content-Type'] = 'application/json'; $response->body = json_encode($response->data, JSON_NUMERIC_CHECK); } else if ($type == 'xml') { $response->headers['Content-Type'] = 'application/xml'; $response->body = $this->_EncodeXML($response->data); } else if ($type == 'html') { $response->headers['Content-Type'] = 'text/html'; if (isset($response->context[self::RENDER_TEMPLATE])) { $template = \hoplite\views\TemplateLoader::Fetch($response->context[self::RENDER_TEMPLATE]); $response->body = $template->Render($response->data); } } }