Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Css helper class written in PHP to support the use of variables in CSS

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 css
Octocat-spinner-32 Css.php
Octocat-spinner-32 README
README
This is a really basic helper class that takes an associative arrays as a constructor parameter and then parses the files contained in the "/css" directory replacing the keys with the values. 

Basic use. 

Let's say whe have a style.css file in the "css/" directory which holds the following code

html, body{
	color:{textColor};
	background-color:{backgroundColor};
}

//This preloads and convert all files that are found in the "css/" directory
//you can change this parameter by changing the $cssDir private variable
$css = new Css(array("{textColor}" => "black", "{backgroundColor}" => "white"));
//This recreates the previously loaded and converted file files in the $outCssDir directory 
$css->renderToFile();

//we have a file called style.css in the directory ../css that holds the following code:
html, body{
	color:black;
	background-color:white;
}
//this just echoes a <style> block
$css->render();

//the following element is rendered
<style>
html, body{
	color:black;
	background-color:white;
}
</style>
Something went wrong with that request. Please try again.