@@ -7,6 +7,9 @@ |
||
7 | 7 | $this->templateFunction = $templateFunction; |
8 | 8 | } |
9 | 9 | |
10 | + /** |
|
11 | + * @param string $val |
|
12 | + */ |
|
10 | 13 | public function html($val) { |
11 | 14 | return $this->templateFunction->run(['<template>' . $val . '</template>']); |
12 | 15 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Transphporm\Formatter; |
3 | 3 | class HTMLFormatter { |
4 | - private $templateFunction; |
|
4 | + private $templateFunction; |
|
5 | 5 | |
6 | - public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { |
|
7 | - $this->templateFunction = $templateFunction; |
|
8 | - } |
|
6 | + public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { |
|
7 | + $this->templateFunction = $templateFunction; |
|
8 | + } |
|
9 | 9 | |
10 | - public function html($val) { |
|
10 | + public function html($val) { |
|
11 | 11 | return $this->templateFunction->run(['<template>' . $val . '</template>']); |
12 | 12 | } |
13 | 13 |
@@ -8,12 +8,12 @@ |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | public function html($val) { |
11 | - return $this->templateFunction->run(['<template>' . $val . '</template>']); |
|
11 | + return $this->templateFunction->run(['<template>'.$val.'</template>']); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function debug($val) { |
15 | 15 | ob_start(); |
16 | 16 | var_dump($val); |
17 | - return $this->html('<pre>' . ob_get_clean() . '</pre>'); |
|
17 | + return $this->html('<pre>'.ob_get_clean().'</pre>'); |
|
18 | 18 | } |
19 | 19 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $result = []; |
42 | 42 | if ($newNode->tagName === 'template') { |
43 | 43 | foreach ($newNode->childNodes as $node) { |
44 | - if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss); |
|
44 | + if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss); |
|
45 | 45 | else $result[] = $this->getClonedElement($node, $tss); |
46 | 46 | } |
47 | 47 | } |
@@ -25,13 +25,18 @@ discard block |
||
25 | 25 | $selector = $this->readArray($args, 1); |
26 | 26 | $tss = $this->readArray($args, 2); |
27 | 27 | |
28 | - if (trim($args[0])[0] === '<') $xml = $args[0]; |
|
29 | - else $xml = $this->filePath->getFilePath($args[0]); |
|
28 | + if (trim($args[0])[0] === '<') { |
|
29 | + $xml = $args[0]; |
|
30 | + } else { |
|
31 | + $xml = $this->filePath->getFilePath($args[0]); |
|
32 | + } |
|
30 | 33 | |
31 | 34 | $newTemplate = new \Transphporm\Builder($xml, $tss ? $this->filePath->getFilePath($tss) : null); |
32 | 35 | |
33 | 36 | $doc = $newTemplate->output($this->elementData->getData($element), true)->body; |
34 | - if ($selector != '') return $this->templateSubsection($doc, $selector); |
|
37 | + if ($selector != '') { |
|
38 | + return $this->templateSubsection($doc, $selector); |
|
39 | + } |
|
35 | 40 | |
36 | 41 | return $this->getTemplateContent($doc->documentElement, $tss); |
37 | 42 | |
@@ -41,8 +46,11 @@ discard block |
||
41 | 46 | $result = []; |
42 | 47 | if ($newNode->tagName === 'template') { |
43 | 48 | foreach ($newNode->childNodes as $node) { |
44 | - if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss); |
|
45 | - else $result[] = $this->getClonedElement($node, $tss); |
|
49 | + if (isset($node->tagName) && $node->tagName === 'template') { |
|
50 | + $result[] = $this->getTemplateContent($node, $tss); |
|
51 | + } else { |
|
52 | + $result[] = $this->getClonedElement($node, $tss); |
|
53 | + } |
|
46 | 54 | } |
47 | 55 | } |
48 | 56 | return $result; |
@@ -62,7 +70,9 @@ discard block |
||
62 | 70 | |
63 | 71 | private function getClonedElement($node, $tss) { |
64 | 72 | $clone = $node->cloneNode(true); |
65 | - if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate'); |
|
73 | + if ($tss != null && $clone instanceof \DomElement) { |
|
74 | + $clone->setAttribute('transphporm', 'includedtemplate'); |
|
75 | + } |
|
66 | 76 | return $clone; |
67 | 77 | } |
68 | 78 | } |