Make sure that injected variables do not break the CSS generation

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-01-26 17:03:22 +01:00
parent d8e0a6ee32
commit 73ae7b0c5f
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 15 additions and 0 deletions

View File

@ -63,6 +63,9 @@ class SCSSCacher {
/** @var ICache */
protected $depsCache;
/** @var null|string */
protected $injectedVariables = null;
/**
* @param ILogger $logger
* @param Factory $appDataFactory
@ -268,10 +271,22 @@ class SCSSCacher {
* @return string SCSS code for variables from OC_Defaults
*/
private function getInjectedVariables() {
if ($this->injectedVariables !== null)
return $this->injectedVariables;
$variables = '';
foreach ($this->defaults->getScssVariables() as $key => $value) {
$variables .= '$' . $key . ': ' . $value . ';';
}
// check for valid variables / otherwise fall back to defaults
try {
$scss = new Compiler();
$scss->compile($variables);
$this->injectedVariables = $variables;
} catch (ParserException $e) {
$this->logger->error($e, ['app' => 'core']);
}
return $variables;
}