public function testSetGetForceCompile() { $provider = new ArrayProvider(['test.htpl' => '{var}']); $htpl = new Htpl($provider); $this->assertSame(false, $htpl->getOptions()['forceCompile']); $this->assertSame(false, $htpl->getForceCompile()); $htpl->setForceCompile(true); $this->assertSame(true, $htpl->getOptions()['forceCompile']); $this->assertSame(true, $htpl->getForceCompile()); }
/** * Compiles and returns the compiled template for the given template name. * * @param string $templateName Template that should be compiled. * * @return Template * @throws HtplException */ public function getCompiledTemplate($templateName) { // first, let's try to get it from cache $layout = false; if (!$this->htpl->getForceCompile()) { $layout = $this->getFromCache($templateName); } if (!$layout) { // do the compile $layout = $this->compileLayout($templateName); // cache the result if (!$this->htpl->getForceCompile()) { $this->htpl->getCache()->write($templateName, serialize($layout)); } } // create Template instance $template = new Template($this->htpl, $layout->getSource()); return $template; }