rbss
Ruby Styling Sheets. Turn Ruby code into valid, minified CSS.
Installation
In your Gemfile
gem rbss
Usage
Currently, all rbss files are not cached and evaluated on run time.
In layouts/application.html.erb
(or otherwise), include the line
<%= rbss('file,names,here') %>
Do not include the .rbss file extension with each name.
In app/assets/stylesheets
, create some files: file.rbss
, names.rbss
, here.rbss
, etc etc.
The files will be evaluated to minified CSS and replace <%= rbss('file,names,here') %>
.
Example
A simple example
body do
color 'black'
width '95px'
end
span '.bacon' do
padding '50px'
font_size '16px'
div '#div' do
color 'yellow'
div '.class' do
width '44px'
end
end
div '.potato' do
text_align 'right'
end
end
_ '#cats' do
height '100px'
end
evaluates to
body{color:black;width:95px;}span.bacon{padding:50px;font-size:16px;}span.bacon div#div{color:yellow;}span.bacon div#div div.class{width:44px;}span.bacon div.potato{text-align:right;}#cats{height:100px;}
A more sexy example
#custom logic
def fake_bacon
'95px'
end
def super_fake_bacon(value)
value.downcase
end
super_duper_fake_bacon = '1px 1px'
#rbss
body '#okay.goodbye' do
width fake_bacon
color super_fake_bacon("WHITE")
a '.success' do
margin super_duper_fake_bacon
end
end
evaluates to
body#okay.goodbye{width:95px;color:white;}body#okay.goodbye a.success{margin:1px 1px;}
Copyright
Copyright (c) 2013 Gabe Scholz. See LICENSE.txt for further details.