CSS server side pre processor

By rob

While I was going through links on smashing magazine and I come across the following link:

http://www.shauninman.com/archive/2007/06/27/css_server_side_pre_processor 

Its using php to call in constants and variables to place throughout the whole of the CSS document.

I.e. 

@server variables
{
    $variableName1: defaultVariableValue;
    $variableName2: defaultVariableValue;
    $variableName3: defaultVariableValue;
}

body { background-color: $variableName; }

will output: 

body { background-color: defaultVariableValue; }

Would be interesting to find if this method would work using ASP or .NET, anyone up for a challenge?

Going through the article,comments and links on the site I noticed that the css was also in nested declarations.
I really like the idea of using nested declarations, does this actually work? (note to self: test and play with this!) 

div {
    /* comment for div */
    color: green;
    p {
        /* comment for div p */
        color: red;
        b { color: blue;
    }
}

Source: http://blog.airbladesoftware.com/2006/12/11/cssdryer-dry-up-your-css
Will have to put this to the test to see if its all compliant etc. 

I've had a quick look on the web for asp versions of the php variable css sheet and returned the following:
http://www.neopoleon.com/home/blogs/neo/archive/2004/03/06/8705.aspx

Not too happy about the title though! "Screw standards - let's add variable support to CSS right this minute".

I think this is one for the techies to continue!


Edited: Adding resource link http://nubyonrails.com/articles/dynamic-css 

Related posts