consolidate-build
v1.1.0
Published
Does for languages that can be 'built' what consolidate.js does for templates
Downloads
20
Readme
consolidate-build
Does for languages that can be 'built' what consolidate.js does for templates
Installation
$ npm install consolidate-build
Supported languages
All template engines supported by consolidate work in consolidate-build.
In addition to those, consolidate build adds:
- coffee-script (website)
- less (website)
- markdown - will use marked, discount, markdown-js or markdown depending on which one is installed (in that order of precedence if multiple markdown parsers are installed).
- sass (website)
- stylus (website)
NOTE: you must still install the engines you wish to use, add them to your package.json dependencies.
API
All templates supported by this library may be rendered using the signature (path[, locals], callback)
or .render(str[, locals], callback)
as shown below.
NOTE: All this example code uses build.less for the less stylsheet language. Replace less with whatever language you are using. For exmaple, use build.stylus for stylus, build.markdown or build.md for markdown, etc. console.log(build)
for the full list of identifiers.
var build = require('consolidate-build');
build.less('styles/style.less', { compress: true }, function(err, css){
if (err) throw err;
console.log(css);
});
Or without options / local variables:
var build = require('consolidate-build');
build.less('styles/style.less', function(err, css){
if (err) throw err;
console.log(css);
});
To dynamically pass the engine, simply use the subscript operator and a variable:
var build = require('consolidate-build')
, name = 'less';
build[name]('styles/style.css', function(err, css){
if (err) throw err;
console.log(css);
});
Without a file
All the languages support being built without a file being present. To do this ismply use the render method.
build.less('.class { width: 1 + 1 }', { compress: true}, function(err, css){
if (err) throw err;
console.log(css);
});