Commit 0a56158c by Sindre Sorhus

Convert the options to camelCase. Fixes #43

Still supporting the old style though
parent ece89940
...@@ -19,12 +19,12 @@ var sass = require('node-sass'); ...@@ -19,12 +19,12 @@ var sass = require('node-sass');
sass.render(scss_content, callback [, options]); sass.render(scss_content, callback [, options]);
``` ```
Especially, the options argument is optional. It support two attribute: `include_paths` and `output_style`, both of them are optional. Especially, the options argument is optional. It support two attribute: `includePaths` and `outputStyle`, both of them are optional.
`include_paths` is an `Array`, you can add a sass import path. `includePaths` is an `Array`, you can add a sass import path.
`output_style` is a `String`, its value should be one of `'nested', 'expanded', 'compact', 'compressed'`. `outputStyle` is a `String`, its value should be one of `'nested', 'expanded', 'compact', 'compressed'`.
[Important: currently the argument `output_style` has some problem which may cause the output css becomes nothing because of the libsass, so you should not use it now!] [Important: currently the argument `outputStyle` has some problem which may cause the output css becomes nothing because of the libsass, so you should not use it now!]
Here is an example: Here is an example:
...@@ -32,7 +32,7 @@ Here is an example: ...@@ -32,7 +32,7 @@ Here is an example:
var sass = require('node-sass'); var sass = require('node-sass');
sass.render('body{background:blue; a{color:black;}}', function(err, css){ sass.render('body{background:blue; a{color:black;}}', function(err, css){
console.log(css) console.log(css)
}/*, { include_paths: [ 'lib/', 'mod/' ], output_style: 'compressed' }*/); }/*, { includePaths: [ 'lib/', 'mod/' ], outputStyle: 'compressed' }*/);
``` ```
## Connect/Express middleware ## Connect/Express middleware
......
...@@ -13,20 +13,20 @@ try { ...@@ -13,20 +13,20 @@ try {
if (binding === null) { if (binding === null) {
throw new Error('Cannot find appropriate binary library for node-sass'); throw new Error('Cannot find appropriate binary library for node-sass');
} }
var toString = Object.prototype.toString;
SASS_OUTPUT_STYLE = { var SASS_OUTPUT_STYLE = {
nested: 0, nested: 0,
expanded: 1, expanded: 1,
compact: 2, compact: 2,
compressed: 3 compressed: 3
}; };
exports.render = function(css, callback, options) { exports.render = function(css, callback, options) {
var paths, style; var paths, style;
typeof options != "object" && (options = {}); options = typeof options !== 'object' ? {} : options;
paths = options.include_paths || []; paths = options.include_paths || options.includePaths || [];
if (!((style = options.output_style) in SASS_OUTPUT_STYLE)) { style = SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0;
style = 'nested'; return binding.render(css, callback, paths.join(':'), style);
}
return binding.render(css, callback, paths.join(':'), SASS_OUTPUT_STYLE[style]);
}; };
exports.middleware = require('./lib/middleware'); exports.middleware = require('./lib/middleware');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment