From cbe37079b2519e6a79696ab6525a61498ab3c3a6 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Tue, 30 Jul 2013 15:56:29 +0200 Subject: [PATCH] convert ini replacements to less vars first This makes it possible to safely overwrite ini replacements from within any less file --- lib/exe/css.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/exe/css.php b/lib/exe/css.php index 04516e8ba..0157e6a40 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -154,6 +154,9 @@ function css_out(){ // apply style replacements $css = css_applystyle($css,$tplinc); + print $css; + + // parse LESS $less = new lessc(); $css = $less->compile($css); @@ -188,15 +191,21 @@ function css_applystyle($css,$tplinc){ $styleini = css_styleini($tplinc); if($styleini){ - $css = strtr($css,$styleini['replacements']); - + // we convert ini replacements to LESS variable names + // and build a list of variable: value; pairs $less = ''; foreach($styleini['replacements'] as $key => $value){ - $key = trim($key, '_'); - $key = '@ini_'.$key; - $less .= "$key: $value;\n"; + $lkey = trim($key, '_'); + $lkey = '@ini_'.$lkey; + $less .= "$lkey: $value;\n"; + + $styleini['replacements'][$key] = $lkey; } + // we now replace all old ini replacements with LESS variables + $css = strtr($css, $styleini['replacements']); + + // now prepend the list of LESS variables as the very first thing $css = $less.$css; } return $css; -- GitLab