Commit a84fcea4 by Jakob Heuser

Standardizes Readme to Spaces

While updating the readme, there was inconsistency between tabs and spaces
this makes it all-spaces, which is in alignment with the JS standards for
the project. (Plus, mixing the two is some horrible form of evil)
parent 69a45603
...@@ -42,7 +42,9 @@ If this project is missing an API or command line flag that has been added to [l ...@@ -42,7 +42,9 @@ If this project is missing an API or command line flag that has been added to [l
## Install ## Install
npm install node-sass ```
npm install node-sass
```
Some users have reported issues installing on Ubuntu due to `node` being registered to another package. [Follow the official NodeJS docs](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) to install NodeJS so that `#!/usr/bin/env node` correctly resolved. Some users have reported issues installing on Ubuntu due to `node` being registered to another package. [Follow the official NodeJS docs](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) to install NodeJS so that `#!/usr/bin/env node` correctly resolved.
...@@ -53,18 +55,17 @@ Compiling versions 0.9.4 and above on Windows machines requires [Visual Studio 2 ...@@ -53,18 +55,17 @@ Compiling versions 0.9.4 and above on Windows machines requires [Visual Studio 2
```javascript ```javascript
var sass = require('node-sass'); var sass = require('node-sass');
sass.render({ sass.render({
file: scss_filename, file: scss_filename,
[, options..] [, options..]
}, function(err, result) { /*...*/ }); }, function(err, result) { /*...*/ });
// OR // OR
var result = sass.renderSync({ var result = sass.renderSync({
data: scss_content data: scss_content
[, options..] [, options..]
}); });
``` ```
### Options ### Options
The API for using node-sass has changed, so that now there is only one options hash. In the options hash, some items are optional, others may be mandatory depending on circumstances. The API for using node-sass has changed, so that now there is only one options hash. In the options hash, some items are optional, others may be mandatory depending on circumstances.
#### file #### file
...@@ -81,11 +82,11 @@ The callback function is passed a results object, containing the following keys: ...@@ -81,11 +82,11 @@ The callback function is passed a results object, containing the following keys:
* `css` - The compiled CSS. Write this to a file, or serve it out as needed. * `css` - The compiled CSS. Write this to a file, or serve it out as needed.
* `map` - The source map * `map` - The source map
* `stats` - An object containing information about the compile. It contains the following keys: * `stats` - An object containing information about the compile. It contains the following keys:
* `entry` - The path to the scss file, or `data` if the source was not a file * `entry` - The path to the scss file, or `data` if the source was not a file
* `start` - Date.now() before the compilation * `start` - Date.now() before the compilation
* `end` - Date.now() after the compilation * `end` - Date.now() after the compilation
* `duration` - *end* - *start* * `duration` - *end* - *start*
* `includedFiles` - Absolute paths to all related scss files in no particular order. * `includedFiles` - Absolute paths to all related scss files in no particular order.
#### error #### error
`error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function. `error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function.
...@@ -164,8 +165,8 @@ node-sass supports standard node style asynchronous callbacks with the signature ...@@ -164,8 +165,8 @@ node-sass supports standard node style asynchronous callbacks with the signature
```javascript ```javascript
var sass = require('node-sass'); var sass = require('node-sass');
sass.render({ sass.render({
file: '/path/to/myFile.scss', file: '/path/to/myFile.scss',
data: 'body{background:blue; a{color:black;}}', data: 'body{background:blue; a{color:black;}}',
success: function(result) { success: function(result) {
// result is an object: v2 change // result is an object: v2 change
console.log(result.css); console.log(result.css);
...@@ -174,27 +175,27 @@ sass.render({ ...@@ -174,27 +175,27 @@ sass.render({
}, },
error: function(error) { // starting v2.1 error is an Error-typed object error: function(error) { // starting v2.1 error is an Error-typed object
// error is an object: v2 change // error is an object: v2 change
console.log(error.message); console.log(error.message);
console.log(error.status); // changed from code to status in v2.1 console.log(error.status); // changed from code to status in v2.1
console.log(error.line); console.log(error.line);
console.log(error.column); // new in v2 console.log(error.column); // new in v2
}, },
importer: function(url, prev, done) { importer: function(url, prev, done) {
// url is the path in import as is, which libsass encountered. // url is the path in import as is, which libsass encountered.
// prev is the previously resolved path. // prev is the previously resolved path.
// done is an optional callback, either consume it or return value synchronously. // done is an optional callback, either consume it or return value synchronously.
someAsyncFunction(url, prev, function(result){ someAsyncFunction(url, prev, function(result){
done({ done({
file: result.path, // only one of them is required, see section Sepcial Behaviours. file: result.path, // only one of them is required, see section Sepcial Behaviours.
contents: result.data contents: result.data
}); });
}); });
// OR // OR
var result = someSyncFunction(url, prev); var result = someSyncFunction(url, prev);
return {file: result.path, contents: result.data}; return {file: result.path, contents: result.data};
}, },
includePaths: [ 'lib/', 'mod/' ], includePaths: [ 'lib/', 'mod/' ],
outputStyle: 'compressed' outputStyle: 'compressed'
}, function(error, result) { }, function(error, result) {
// starting v2.1 the node-style callback has error (Object) and result (Object) // starting v2.1 the node-style callback has error (Object) and result (Object)
// the objects are identical to those provided for the error and success keys // the objects are identical to those provided for the error and success keys
...@@ -202,25 +203,25 @@ sass.render({ ...@@ -202,25 +203,25 @@ sass.render({
}); });
// OR // OR
var result = sass.renderSync({ var result = sass.renderSync({
file: '/path/to/file.scss', file: '/path/to/file.scss',
data: 'body{background:blue; a{color:black;}}', data: 'body{background:blue; a{color:black;}}',
outputStyle: 'compressed', outputStyle: 'compressed',
outFile: '/to/my/output.css', outFile: '/to/my/output.css',
sourceMap: true, // or an absolute or relative (to outFile) path sourceMap: true, // or an absolute or relative (to outFile) path
importer: function(url, prev, done) { importer: function(url, prev, done) {
// url is the path in import as is, which libsass encountered. // url is the path in import as is, which libsass encountered.
// prev is the previously resolved path. // prev is the previously resolved path.
// done is an optional callback, either consume it or return value synchronously. // done is an optional callback, either consume it or return value synchronously.
someAsyncFunction(url, prev, function(result){ someAsyncFunction(url, prev, function(result){
done({ done({
file: result.path, // only one of them is required, see section Sepcial Behaviours. file: result.path, // only one of them is required, see section Sepcial Behaviours.
contents: result.data contents: result.data
}); });
}); });
// OR // OR
var result = someSyncFunction(url, prev); var result = someSyncFunction(url, prev);
return {file: result.path, contents: result.data}; return {file: result.path, contents: result.data};
}, },
})); }));
console.log(result.css); console.log(result.css);
......
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