jverkoey/nimbus — pull request #106 by dbarden (2011-11-03 01:52:12+00:00)
Title: CSS Stylesheets in Stylus notation

Here is a first version for your review :)

These patches enable a user to describe the CSS Stylesheets using the [Stylus](http://learnboost.github.com/stylus/) format.

The Chameleon server was modified to handle the request for any file with an extension '.styl' as a Stylus stylesheet. It will compile the CSS and return the request with the CSS in the standard format, one that can be parsed by Nimbus.

There are some tricks to make it work, since the Stylus format is not parsed by Nimbus:
* The user must have the Chameleon server running, or else he won't be able to perform the format translation;
* When initializing the NIStyleSheet, it must be initialized with `loadFromDisk:NO`. Or else Nimbus will try to parse the Stylus format and will break;
* After initializing the NIStyleSheet, the user must fetch the stylesheet from the server. It should be used to avoid not having the stylesheet in a first moment and be dependent on the file modification for Nimbus to load the stylesheet. Due to this reason I modified the file `src/css/src/NIChameleonObserver.h` to expose the method `(void)downloadStylesheetWithFilename:(NSString *)path`

Basically, the initialization must be done as (the complete example can be seen in `examples/css/StylusDemo/StylusDemo/ViewController.m`):

NIStylesheet* stylesheet = [stylesheetCache stylesheetWithPath:@"root/root.styl" loadFromDisk:NO];
_dom = [[NIDOM alloc] initWithStylesheet:stylesheet];
NIChameleonObserver *chameleon = [(AppDelegate *)[UIApplication sharedApplication].delegate chameleonObserver];
[chameleon downloadStylesheetWithFilename:@"root/root.styl"];

Please let me know your thoughts. This implementation was the result of some tests that I did, but I hope that it can lead to something cool :)