Announcing Switch, the CSS Preprocessor!

John J. Lee jjl at pobox.com
Thu Aug 10 18:01:39 EDT 2006


"Dave" <davidworley at gmail.com> writes:

> It's not tied deeply to mod_python.
> 
> The processor works like this:
> 
> You create an "sss" file, using Switch specific features. Then, you
> place the file under Apache/mod_python OR you can use the command-line
> Switch tool to process the SSS file and output a CSS file. In this way,
> it works very similar to an XSLT transformation in that you write using
> a shorthand method that outputs to a more verbose, crystallized file.
> 
> This way, it's platform agnostic. I'm also kicking around the idea of a
> GUI tool.
> 
> The reason we didn't give it the ability to "preprocess if changed" is
> because we're looking forward to implementing a system that can handle
> conditional statements:
> 
> if $BROWSER is IE and $BROWSER_VERSION > 6 {
> 
> /* output this */
> 
> } else {
> 
> /* output this */
> 
> }
> 
> This would need to be compiled with every request. Maybe, though, we
> could have different settings in which you could compile with every
> request, compile on change, or precompile...
[...]

How about a mod_rewrite rule or two to auto-generate the .css files
from the .sss files?  That way, you retain really fast static-file
Apache serving of CSS, no Python process involved except for the very
first hit on each .css file.  To invalidate the cache, rm *.css (you
can do this as part of the code promotion process).  We've used this
at work with PDF files, and it works nicely.

I think you could still implement the browser detection thing exactly
as you describe it with this scheme just by auto-generating more than
one .css file per .sss file (perhaps making use of CSS imports), and
referencing the appropriate .css file in your dynamically-generated
HTML (or, if static HTML and JavaScript, using document.write to
reference the right .css file).


John



More information about the Python-list mailing list