register helper functions that can be used with LESS, the same way that handlebars helpers are used in templates.
HEADS UP! This currently is not an npm module!!!! I need to come up with a different name, this is a placeholder!!!
Install with npm
$ npm i less-css-helpers --save
HEADS UP! This currently is not an npm module!!!! I need to come up with a different name, this is a placeholder!!!
var less = require('less');
var register = require('less-css-helpers')(less);
Register a single helper
Example assets helper, that might be used for dynamically calculating the path to a project's assets directory, relative to the css file's destination.
register.helper('assets', function (path) {
return 'dist/' + path.value + '/assets/css';
});
Register multiple helpers
register.helpers({
assets: function (path) {
return 'dist/' + path.value + '/assets/css';
},
foo: function () {},
bar: function () {}
});
Example of how to use the assets helper we just created above:
@theme: "blah";
@assets: assets("@{theme}");
.image {
background: url("@{assets}/bar.png");
}
Results in:
.image {
background: url("dist/blah/assets/css/bar.png");
}
The following properties are exposed on the this object:
options: Any options passed to render are exposed on this objectless: the less objectExample
register.helper('assets', function (path) {
return path.join(path.value, this.options.assets);
});
less: Leaner CSS
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 29, 2015.