diff --git a/README.md b/README.md index 9840a87..7fc96b0 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,139 @@ progress on the new version. bless.js [![Stories in Ready](https://badge.waffle.io/paulyoung/bless.js.png)](http://waffle.io/paulyoung/bless.js) ======= +Bless.js prepares files so that they are suitable for older versions of +Internet Explorer. + -about ------ +Build Tools +----------- + +In addition to the `blessc` command line tool. There are third-party +integrations for existing build tools. + +### Grunt with 'grunt-bless' ### + +Integrate Bless.js in to your Grunt builds with the [grunt-bless](https://github.com/Ponginae/grunt-bless) +plugin. + +### Gulp with 'gulp-bless' ### + +[gulp-bless](https://github.com/adam-lynch/gulp-bless) integrates Bless.js into your Gulp builds. + +Node.js API +----------- + +Bless.js exposes an API that can be used to integrate into custom build tools. + +### Parser(options) ### + +When creating a new `Parser` object you must pass it an object containing the +output filename and the desired options (see below). + +The parser object is linked to a specific output location passed to the +constructor. It is recommended to create a new instance of the parser for each +output file rather that reusing it. + +```javascript +var Parser = requre('bless').Parser, + parser = new Parser({ + 'output': 'myfile.css', + 'options': {} + }); +``` + +#### parser.parse(css_str, callback) #### + +Parses the contents of `css_str` and executes `callback`. + +```javascript +parser.parse('#an-element { color: red }', function (err, files, numSelectors) { + // do something with `files` here. + console.log(files); +}); +``` + +The callback should accept three parameters, `err`, `files`, `numSelectors`. The +`err` parameter contains information regarding any error that occurred during +parsing or `null` if there was no error. + +The `files` parameter contains an array of objects that contains the file and +where it should be written to. The above example will output something +similar to. + +```javascript +[ + { + 'filename': 'myfile.css', + 'content': '#an-element { color: red }' + } +] +``` + +The `numSelectors` parameter contains a integer total of the number of selectors +found in the parsed CSS. + +#### Parser.cleanup(options, output, callback) #### + +A static method that will enumerate any files generated by bless. This is +helpful for cleaning up any files from previous runs of the parser. + +```javascript +Parser.cleanup({}, 'myfile.css', function (err, files) { + // do something with `files` here. + console.log(files); +}) +``` + +The `options` and `output` parameters should be the options passed to the +`Parser` object that generated the files. The `callback` parameter should be a +function that accepts two parameters `err` and `files`. + +The `err` parameter will contain any error that occurred while attempting to +enumerate the files or `null` if no error occurred. The `files` parameter is the +list of filenames that were generated. + +### Options #### + +#### options.compress (-x, --compress) #### + +Type: `Boolean` +Default value: `false` + +Compress the css output added by bless. This _does not_ compress the CSS you +wrote. For that you should use a CSS minifier. + +#### options.cleanup (--no-cleanup) #### + +Type: `Boolean` +Default value: `true` + +Clean up files generated by bless before proceeding. + +#### options.force (-f, --force) #### + +Type: `Boolean` +Default value: `false` + +This will allow bless to overwrite the input file. + +#### options.imports (--no-imports) #### + +Type: `Boolean` +Default value: `true` +Added: v3.0.3 + +Enable or disable the use of `@import` in generated CSS files. + +#### options.cacheBuster (--no-cache-buster) #### + +Type: `Boolean` +Default value: `true` -For more information, visit . +Add or remove a cache-buster parameter from the generated CSS files. -license +License ------- See `LICENSE` file.