Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[CompassFilter] Allow config files to be included when compiling with compass #563

Open
wants to merge 1 commit into from

2 participants

@fearlsgroove

No description provided.

@kriswallsmith

This wouldn't work if one of the config files uses the __FILE__ constant.

@fearlsgroove

As in if someone tried to reference a file relative to itself another in the ruby config file? I don't see a way to work around that, but it seems like something you could avoid in the context of this specific use case. I'm also not a ruby coder, so maybe I wouldn't know.

If you have a suggested fix I'd be happy to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/Assetic/Filter/CompassFilter.php
View
19 src/Assetic/Filter/CompassFilter.php
@@ -52,6 +52,7 @@ class CompassFilter extends BaseProcessFilter implements DependencyExtractorInte
private $httpGeneratedImagesPath;
private $generatedImagesPath;
private $httpJavascriptsPath;
+ private $configFiles;
private $homeEnv = true;
public function __construct($compassPath = '/usr/bin/compass', $rubyPath = null)
@@ -183,6 +184,11 @@ public function setHttpJavascriptsPath($httpJavascriptsPath)
$this->httpJavascriptsPath = $httpJavascriptsPath;
}
+ public function setConfigFiles($configFiles)
+ {
+ $this->configFiles = $configFiles;
+ }
+
public function setHomeEnv($homeEnv)
{
$this->homeEnv = $homeEnv;
@@ -294,6 +300,15 @@ public function filterLoad(AssetInterface $asset)
$optionsConfig['fonts_dir'] = $this->fontsDir;
}
+ $configOutput = '';
+
+ // config files go first, if any
+ if (!empty($this->configFiles)) {
+ foreach ($this->configFiles as $file) {
+ $configOutput .= file_get_contents($file)."\n";
+ }
+ }
+
// options in configuration file
if (count($optionsConfig)) {
$config = array();
@@ -307,9 +322,11 @@ public function filterLoad(AssetInterface $asset)
$config[] = sprintf('%s = %s', $name, $this->formatArrayToRuby($value));
}
}
+ }
+ if ($configOutput || $config) {
$configFile = tempnam($tempDir, 'assetic_compass');
- file_put_contents($configFile, implode("\n", $config)."\n");
+ file_put_contents($configFile, $configOutput . implode("\n", $config)."\n");
$pb->add('--config')->add($configFile);
}
Something went wrong with that request. Please try again.