33 $this->emberBin = $handlebarsBin;
40 ?
array($this->nodeBin, $this->emberBin)
41 :
array($this->emberBin));
44 $templateName = basename($sourcePath);
46 throw new \LogicException(
'The embed-precompile filter requires that assets have a source path set');
50 $inputPath = $inputDirPath.DIRECTORY_SEPARATOR.$templateName;
53 file_put_contents($inputPath, $asset->
getContent());
55 $pb->add($inputPath)->add(
'-f')->add($outputPath);
57 $process = $pb->getProcess();
58 $returnCode = $process->run();
63 if (127 === $returnCode) {
64 throw new \RuntimeException(
'Path to node executable could not be resolved.');
67 if (0 !== $returnCode) {
68 if (file_exists($outputPath)) {
74 if (!file_exists($outputPath)) {
75 throw new \RuntimeException(
'Error creating output file.');
78 $compiledJs = file_get_contents($outputPath);
static createTemporaryFile($prefix)
Creates a temporary file.
static fromProcess(Process $proc)
Precompiles Handlebars templates for use in the Ember.js framework.
filterLoad(AssetInterface $asset)
Filters an asset after it has been loaded.
__construct($handlebarsBin='/usr/bin/ember-precompile', $nodeBin=null)
filterDump(AssetInterface $asset)
Filters an asset just before it's dumped.
getSourcePath()
Returns the relative path for the source asset.
createProcessBuilder(array $arguments=array())
getContent()
Returns the loaded content of the current asset.
An asset has a mutable URL and content and can be loaded and dumped.
Create styles array
The data for the language used.
static createThrowAwayDirectory($prefix)
Creates a throw-away directory.
setContent($content)
Sets the content of the current asset.