public function testProcessOnlyIncludesRequirementsOnce()
 {
     $template = new SSViewer(array('SSViewerTestProcess'));
     $basePath = dirname($this->getCurrentRelativePath()) . '/forms';
     $backend = new Requirements_Backend();
     $backend->set_combined_files_enabled(false);
     $backend->combine_files('RequirementsTest_ab.css', array($basePath . '/RequirementsTest_a.css', $basePath . '/RequirementsTest_b.css'));
     Requirements::set_backend($backend);
     $this->assertEquals(1, substr_count($template->process(array()), "a.css"));
     $this->assertEquals(1, substr_count($template->process(array()), "b.css"));
     // if we disable the requirements then we should get nothing
     $template->includeRequirements(false);
     $this->assertEquals(0, substr_count($template->process(array()), "a.css"));
     $this->assertEquals(0, substr_count($template->process(array()), "b.css"));
 }
Пример #2
0
 /**
  * Execute the given template, passing it the given data.
  * Used by the <% include %> template tag to process templates.
  * 
  * @param string $template Template name
  * @param mixed $data Data context
  * @param array $arguments Additional arguments
  * @return string Evaluated result
  */
 public static function execute_template($template, $data, $arguments = null, $scope = null)
 {
     $v = new SSViewer($template);
     $v->includeRequirements(false);
     return $v->process($data, $arguments, $scope);
 }
 /**
  * Mimics the bevahiour of $Layout in templates
  * @return HTMLText
  */
 public function RenderLayout()
 {
     $template = $this->findLayout();
     $subtemplateViewer = new SSViewer($template);
     $subtemplateViewer->includeRequirements(false);
     return $subtemplateViewer->process($this->getOwner());
 }