Ejemplo n.º 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());
  }
Ejemplo n.º 2
0
  public function Render($vars = array())
  {
    $__template_data = $this->data;
    $__template_vars = array_merge($this->vars, $vars);
    $render = function () use ($__template_data, $__template_vars) {
      extract($__template_vars);
      eval('?>' . $__template_data . '<' . '?');
    };

    ob_start();

    $error = error_reporting();
    error_reporting($error & ~E_NOTICE);

    $render();

    error_reporting($error);

    if (Profiling::IsProfilingEnabled())
      TemplateLoader::GetInstance()->MarkTemplateRendered($this->name);

    $data = ob_get_contents();
    ob_end_clean();
    return $data;
  }