Hack around a bit, get the job done.
Overrides FilterInterface::filterLoad
public function filterLoad(AssetInterface $asset) {
static $format = <<<'EOF'
#!/usr/bin/env ruby
require %s
%s
options = { :load_path => [],
:source_files => [%s],
:expand_paths => false }
%ssecretary = Sprockets::Secretary.new(options)
secretary.install_assets if options[:asset_root]
print secretary.concatenation
EOF;
$more = '';
foreach ($this->includeDirs as $directory) {
$more .= 'options[:load_path] << ' . var_export($directory, true) . "\n";
}
if (null !== $this->assetRoot) {
$more .= 'options[:asset_root] = ' . var_export($this->assetRoot, true) . "\n";
}
if ($more) {
$more .= "\n";
}
$tmpAsset = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($tmpAsset, $asset
->getContent());
$input = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
file_put_contents($input, sprintf($format, $this->sprocketsLib ? sprintf('File.join(%s, \'sprockets\')', var_export($this->sprocketsLib, true)) : '\'sprockets\'', $this
->getHack($asset), var_export($tmpAsset, true), $more));
$pb = $this
->createProcessBuilder(array(
$this->rubyBin,
$input,
));
$proc = $pb
->getProcess();
$code = $proc
->run();
unlink($tmpAsset);
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)
->setInput($asset
->getContent());
}
$asset
->setContent($proc
->getOutput());
}