coss
v0.0.5
Published
A simple compiler that compiles js to css.
Downloads
7
Readme
COSS
npm install coss
# Or use in browser. Note that only the `coss.min.js` is build for browser.
bower install coss
API
coss
param: source
{ Object | Array }
The source data to compile.
param: indent
{ String }
Default is 4 spaces.
return: { String }
The compiled code.
example:
level = ->
level.count ?= 1
'.level_' + level.count++
# Compile an array css tree.
# The array compiler can use variable as css selector.
coss [
['#basic'
['font-size', '12px']
['opacity', 0.8]
]
[level()
['background', 'red']
['border', '1px solid #fff']
['&:hover'
['background', 'blue']
]
[level()
['margin', '1px']
[level()
['padding', 0]
]
]
]
]
# Compile an object css tree.
coss {
'.level_1':
background: 'red'
border: '1px solid #fff'
'.level_2':
margin: '1px'
'.level_3':
padding: 0
'#another':
'font-size': '12px'
opacity: 0.8
}