Conditions | 4 |
Paths | 6 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
16 | public function compile(array $files, $moduleName, $newModule = false) |
||
17 | { |
||
18 | $output = "'use strict';\n\n"; |
||
19 | $output .= $newModule ? "angular.module('{$moduleName}', [])\n" : "angular.module('{$moduleName}')\n"; |
||
20 | $output .= " .run(['\$templateCache', function (\$templateCache) {\n"; |
||
21 | |||
22 | /* @var $file SplFileInfo */ |
||
23 | foreach ($files as $file) { |
||
24 | $templateId = $file->getRelativePathname(); |
||
25 | $output .= " \$templateCache.put('{$templateId}',\n"; |
||
26 | |||
27 | $html = array(); |
||
28 | foreach (new \SplFileObject($file->getPathname(), 'r') as $line) { |
||
29 | $html[] = ' \'' . str_replace(array("\r", "\n", '\''), array('\r', '\n', '\\\''), $line) . "'"; |
||
30 | } |
||
31 | |||
32 | $output .= implode(" +\n", $html) . ");\n"; |
||
33 | } |
||
34 | |||
35 | $output .= " }])\n"; |
||
36 | $output .= ";\n"; |
||
37 | |||
38 | return $output; |
||
39 | } |
||
40 | } |
||
41 |