Rcss 0.3.1 review

by rbytes.net on

Rcss addresses issue of CSS maintainability

License: MIT/X Consortium License
File size: 0K
Developer: Bragi Ragnarson
0 stars award from rbytes.net

Rcss addresses issue of CSS maintainability. Even a minor change in complex stylesheet usually requires using search-and-replace.

A simple way to fix this flaw is to allow some kind of constant/variable substitution inside CSS. Using Rcss you can achieve that in three ways:

ERB templates

ERB templating is the most flexible solution. It uses standard ERB syntax (the same you can find in rhtml files). ERB allows you to inlude in the CSS values defined in controller. This gives access to database through ActiveRecord and allows database-driven CSS themes.

Access to application data (through ActiveRecord)
Flexible Ruby syntax (allowing programmatic CSS)
Syntax unfamiliar to CSS designers
A bit ugly and sometimes error-prone embedding
Not portable
< % template_color = "#000"
template_background = "#fff"
template_highlight = "#fa3"
% >
body {
color: < %= template_color % >;
background-color: < %= template_background % >;

h1 {
color: < %= template_background % >;
background-color: < %= template_highlight % >;

Server-side Constants

Server-side Constants were originaly developed by Shaun Inman in PHP. SSC extends CSS syntax in a simple way. SCC is cross-platform and easy to use.
Rcss differs from original implementation in two ways :
Constants may have complex values (including spaces and commas)
Includes are not implemented
Simple syntax
SSC-CSS files can be used in both Rails and PHP applications
Only simple constant substitution
@server constants {
template_color: #000;
template_background: #fff;
template_highlight: #fa3;

// Rcss specific (note spaces and commas)
template_font: "Trebuchet MS", "Bitstream Vera Sans", helvetica, sans-serif;

body {
color: template_color;
background-color: template_background;
font-family: template_font;

h1 {
color: template_background;
background-color: template_highlight;
font-family: template_font;

What's New in This Release:
Ruby 1.8.2 is now used for builds, which fixes an invalid GEM problem and allows the software to actually be installed.

Rcss 0.3.1 keywords