After my previous post I’ve had some feedback and help (thanks @Tigraine!), which led me to ask myself the next question. Why not simply host the ruby code in a IronRuby container, calling the ruby code directly? This would, indeed, make my life a lot easier. However, seeing my third point, I think it’s a valid reason to keep going down the path I’m on right now:
“Third, and perhaps the most important reason: I want to learn. Parsing CSS is a nice way to learn how to parse a DSL using Antlr, something I wanted to try for a while. Little did I know that CSS can get pretty complex when adding all those little, unknown, hardly supported features that are in CSS3… I also wanted to get some hands on experience with running an open-source project, although I don’t know if I’ll really get the community input I’m hoping for.”
I want to successfully manage to completely write this in C#, so I will be able to say: “Yes, I know Antlr. See this LessCSS parser? I made it!”.
I’ve also been thinking about advanced scenarios for the library. Having the full CSS structure as an object tree in memory is a pretty interesting thought. How nice would it be to be able to programmatically change some parts of your CSS, based on environment variables? A very silly example: You could have your colors change depending on the time of day, without having to resort to javascript or having different stylesheets. A better example would be the ability to skin your application using user settings. Using (Less)variables for your colors, you can load the stylesheet into your app, replace the variables and BAM! user based skinning without much effort! I think THAT is the way I want this to go.
However!
I think, from a usability standpoint, it would be good to incorporate such an implementation (IronRuby container) into the solution. Why? Because then people should be able to use the HttpHandler right away. Simply hotwire the handler in the web.config, throw in some *.less files and go for it! So that will be part of my adapted roadmap for the first release. Instead of having a full C# port, I want to have a working version which doesn’t need ruby installed. Whichever way to go, if it works, it works!