Skip to content

Instantly share code, notes, and snippets.

@da411d
Last active September 19, 2015 14:29
Show Gist options
  • Save da411d/81c80603ebd6cc952eef to your computer and use it in GitHub Desktop.
Save da411d/81c80603ebd6cc952eef to your computer and use it in GitHub Desktop.
CSS Pre-processor
function preprocessor($text){
$parts = explode("~~~~~~~~~~~~~~~~", $text);
$parts[0] = str_replace("\n",'',$parts[0]);
$parts[0] = str_replace("\r",'',$parts[0]);
$param = explode(";", $parts[0]);
$style = $parts[1];
$params = [];
foreach($param as $p){
if($p){
$params[] = explode(" = ", $p);
}
}
foreach($params as $p){
if($p){
$style = str_replace($p[0], $p[1], $style);
}
}
return $style;
}
$style = file_get_contents('style.css');
$style = preprocessor($style);
echo $style;
body{
background:#000;
font-family: Arial;
letter-spacing: 1px;
font-size:150%;
color:#fafafa;
cursor:default;
margin:0px;
}
_theme_bg_color_ = #000;
_theme_text_color_ = #fafafa;
~~~~~~~~~~~~~~~~
body{
background:_theme_bg_color_;
font-family: Arial;
letter-spacing: 1px;
font-size:150%;
color:_theme_text_color_;
cursor:default;
margin:0px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment