Thursday, November 15, 2007

Syntax Coloring for Dynamic Stylesheets

I often need to dynamically generate stylesheets. Thankfully this path is well worn and solutions are readily available for Ruby on Rails. I chose the ERb/CSS based solution presented here:

Dirt Simple .rcss templates
Simpler than dirt: RESTful Dynamic CSS

If you're in the market, I'd also recommend looking at Sass (Syntactically Awesome StyleSheets). I'll explain my choice in favor of ERb/CSS in a future post.

One of the issues with the ERb/CSS solution is that editors are not aware of the syntax. To remedy this, I have created a plugin for ActiveState's Komodo IDE .

The plugins are here (with the usual disclaimer):

css-erb-highlight-only-1.0.0-ko.xpi
css-erb-highlight-and-check-1.0.0-ko.xpi
rcss-highlight-only-1.0.0-ko.xpi
rcss-highlight-and_check-1.0.0-ko.xpi

The "highlight-and-check" versions provide syntax highlighting, syntax checking, and auto indentation. However due to a shortcoming in ActiveState's tools, the syntax checking is imperfect and you will see syntax errors where there are none. I will remedy this as soon at the tools allow.

It should go without saying that the "highlight-only" versions only provide syntax highlighting, and the "css-erb" and "rcss" versions provide the functionality for the ".css.erb" and ".rcss" extensions respectively.

In a future post, I hope detail how these extensions were created.

I'm using Komodo IDE 4.2 on Mac OS X, but I believe the extensions will work in all Komodo 4 products. Please let me know if they don't.

No comments: