0.1.0 • Published 9 years ago

less-css-helpers v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

less-css-helpers NPM version

register helper functions that can be used with LESS, the same way that handlebars helpers are used in templates.

Install

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

Usage

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);

Registering helpers

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 () {}
});

Using helpers

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");
}

Properties

The following properties are exposed on the this object:

  • options: Any options passed to render are exposed on this object
  • less: the less object

Example

register.helper('assets', function (path) {
  return path.join(path.value, this.options.assets);
});

Related projects

less: Leaner CSS

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on May 29, 2015.