/** * 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 * @param Object $scope * @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); }
public function testProcessOnlyIncludesRequirementsOnce() { $template = new SSViewer(array('SSViewerTestProcess')); $basePath = dirname($this->getCurrentRelativePath()) . '/forms'; $backend = Injector::inst()->create('SilverStripe\\View\\Requirements_Backend'); $backend->setCombinedFilesEnabled(false); $backend->combineFiles('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")); }