public function testPropertyException() { $this->expectException("Transphporm\\Exception"); $this->expectExceptionMessage("TSS Error: Problem carrying out property 'repeat' on Line 2 of tss"); $xml = '<div></div>'; $tss = ' div { repeat: "test"; } '; $template = new \Transphporm\Builder($xml, $tss); $template->output(); }
public function template($val, $element) { $newTemplate = new \Transphporm\Builder($this->baseDir . $val[0]); $newTemplate->setLocale($this->locale); $doc = $newTemplate->output([], true)->body; $newNode = $element->ownerDocument->importNode($doc->documentElement, true); $result = []; if ($newNode->tagName === 'template') { foreach ($newNode->childNodes as $node) { $result[] = $node->cloneNode(true); } } //else $result[] = $newNode; return $result; }
public function run(array $args, \DomElement $element = null) { $selector = $this->readArray($args, 1); $tss = $this->readArray($args, 2); if (trim($args[0])[0] === '<') { $xml = $args[0]; } else { $xml = $this->filePath->getFilePath($args[0]); } $newTemplate = new \Transphporm\Builder($xml, $tss ? $this->filePath->getFilePath($tss) : null); $doc = $newTemplate->output($this->elementData->getData($element), true)->body; if ($selector != '') { return $this->templateSubsection($doc, $selector); } return $this->getTemplateContent($doc, $tss); }
public function testNotWithMoreDepth() { $xml = ' <div class="one"> <p></p> </div> <div class="two"> <p></p> </div> <div class="three"> <p></p> </div> '; $tss = 'p:not("div.two p") {content: "foo"; }'; $template = new \Transphporm\Builder($xml, $tss); $this->assertEquals($this->stripTabs($template->output()->body), $this->stripTabs(' <div class="one"><p>foo</p></div> <div class="two"><p></p></div> <div class="three"><p>foo</p></div> ')); }
public function testImportFromCustomRoot() { $template = new \Transphporm\Builder("<div>test</div>", __DIR__ . DIRECTORY_SEPARATOR . "other/rootImportOverride.tss"); $template->setRootDir(getcwd() . "/tests"); $this->assertEquals('<div>foo</div>', $this->stripTabs($template->output()->body)); }