Permalink
Browse files

Added support of any number of arguments in context helpers and tests

  • Loading branch information...
1 parent d015ea0 commit b03443fe612450568a6245ab969efe6424cf41fb @btd btd committed Jul 28, 2013
Showing with 21 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +5 −6 lib/mincer/engines/less_engine.js
  3. +9 −0 test/engines_test.js
  4. +6 −0 test/fixtures/less_engine/stylesheet.css.less
View
@@ -6,3 +6,4 @@ npm-debug.log
tmp/
doc/
+.idea
@@ -162,15 +162,14 @@ LessEngine.prototype.evaluate = function (context, locals) {
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));
+ _.forEach(locals, function(localFunc, localName) {
+ less.tree.functions[localName] = function() {
+ var extractedLessArguments = _.map(arguments, 'value');
+
+ return new less.tree.Anonymous(localFunc.apply(undefined, extractedLessArguments));
};
});
- _.extend(less.tree.functions, fixedLocals);
-
var parser = new (less.Parser)({
paths: [path.dirname(this.file)].concat(context.environment.paths),
optimization: 1,
View
@@ -25,4 +25,13 @@ describe("Engines", function () {
});
});
+ describe("LESS", function () {
+
+ it("should support context helpers", function () {
+ var asset = env.findAsset("less_engine/stylesheet");
+ assert(asset.toString().match(/\/assets\/ixti-[a-f0-9]{32}.gif/));
+ assert(asset.toString().match(/data:image\/gif;base64/));
+ });
+ });
+
});
@@ -0,0 +1,6 @@
+@var: asset_path("ixti.gif");
+@dataUri: asset_data_uri("ixti.gif");
+
+.class:before { content: @var; }
+.class2 { background-image: @dataUri; }
+

0 comments on commit b03443f

Please sign in to comment.