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:
parent
d8e0a6ee32
commit
73ae7b0c5f
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue