Esempio n. 1
0
    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();
    }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
    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>
		'));
    }
Esempio n. 5
0
 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));
 }