/** * @covers PhCompile\Template\Template::compile * @covers PhCompile\Template\Template::compileAttribute */ public function testCompile() { $this->template->loadHtml(TEST_PATH . 'template/overall.html'); $this->template->setScope(new Scope(json_decode(file_get_contents(TEST_PATH . 'template/overallData.json'), true))); $expectedHtml = file_get_contents(TEST_PATH . 'template/overallCompiled.html'); $this->assertSame($expectedHtml, $this->template->compile()); }
/** * Renders given DOM element as subtemplate. * * @param \DOMElement $domElement DOM element to subrender. * @param Scope $scope Subtemplate Scope object. * @return string Rendered HTML. */ protected function subcompile(\DOMElement $domElement, $scope) { $template = new Template($this->phCompile); /** * Remove ng-repeat attribute so we won't fall into infinite loop while parsing. */ $domElement->removeAttribute('ng-repeat'); /** * Tag element with render class, for easy client-side JavaScript manipulation. */ Utils::addClass($domElement, $this->phCompile->getConfig('compile.class')); $template->setHTML($domElement->ownerDocument->saveHTML($domElement)); $template->setScope($scope); return $template->compile(); }