Skip to content

Commit

Permalink
Merge pull request #98 from btd/less_locals
Browse files Browse the repository at this point in the history
Add context helpers to less engine.
  • Loading branch information
ixti committed Jul 27, 2013
2 parents 3009b52 + 0ef0215 commit d015ea0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/mincer/engines/less_engine.js
Expand Up @@ -156,12 +156,21 @@ function lessImporterSync(file, currentFileInfo, callback, env) {
}

// Render data
LessEngine.prototype.evaluate = function (context/*, locals*/) {
LessEngine.prototype.evaluate = function (context, locals) {
var self = this;

var error = null,
result = null;

var fixedLocals = {};
Object.keys(locals).forEach(function(local) {
fixedLocals[local] = function(lessArg) {
return new less.tree.Anonymous(locals[local](lessArg.value));
};
});

_.extend(less.tree.functions, fixedLocals);

var parser = new (less.Parser)({
paths: [path.dirname(this.file)].concat(context.environment.paths),
optimization: 1,
Expand Down

0 comments on commit d015ea0

Please sign in to comment.