Skip to content

Commit 2e65221

Browse files
authored
Add JavaScriptResource template package
* Add JavaScriptResource template package * Remove JavaScriptResource mustache template submodule * Use getTemplatePath to find JavaScriptResource template from a list of possible locations
1 parent e5cc612 commit 2e65221

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"ext-ctype": "*",
2727
"ext-json": "*",
2828
"mustache/mustache": "^2.13",
29-
"tedivm/jshrink": "~1.0"
29+
"tedivm/jshrink": "~1.0",
30+
"51degrees/fiftyone.pipeline.javascript-templates": "1.*"
3031
},
3132
"require-dev": {
3233
"kint-php/kint": "^3.3",
@@ -41,5 +42,11 @@
4142
"psr-4": {
4243
"fiftyone\\pipeline\\core\\tests\\": "tests/"
4344
}
44-
}
45+
},
46+
"repositories": [
47+
{
48+
"type": "vcs",
49+
"url": "https://github.com/51Degrees/javascript-templates"
50+
}
51+
]
4552
}

javascript-templates

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/JavascriptBuilderElement.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function processInternal($flowData)
176176
}
177177

178178
$vars["_parameters"] = json_encode($jsParams);
179-
180-
$output = $m->render(file_get_contents(__DIR__ . "/../javascript-templates/JavaScriptResource.mustache"), $vars);
179+
180+
$output = $m->render(file_get_contents($this->getTemplatePath()), $vars);
181181

182182
if($this->minify) {
183183
// Minify the output
@@ -190,4 +190,19 @@ public function processInternal($flowData)
190190

191191
return;
192192
}
193+
194+
private function getTemplatePath()
195+
{
196+
$templatePath = '51degrees/fiftyone.pipeline.javascript-templates/JavaScriptResource.mustache';
197+
$prefixes = ['/../../../', '/../vendor/'];
198+
199+
foreach ($prefixes as $prefix) {
200+
$path = __DIR__ . $prefix . $templatePath;
201+
if (file_exists($path)) {
202+
return $path;
203+
}
204+
}
205+
206+
throw new \Exception('Could not find JavaScriptResource template');
207+
}
193208
}

0 commit comments

Comments
 (0)