Пример #1
0
  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());
  }
Пример #2
0
 static public function Import($template, $vars)
 {
   echo TemplateLoader::Fetch($template)->Render($vars);
 }
Пример #3
0
 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);
     }
   }
 }