Skip to content

Commit

Permalink
fix string interpolation with mixins, closes #272
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed May 19, 2011
1 parent 0726b9b commit 853604a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/less/tree/quoted.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ tree.Quoted.prototype = {
},
eval: function (env) {
var that = this;
this.value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
}).replace(/@\{([\w-]+)\}/g, function (_, name) {
var v = new(tree.Variable)('@' + name, that.index).eval(env);
return v.value || v.toCSS();
});
return this;
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
}
};

Expand Down
6 changes: 6 additions & 0 deletions test/css/strings.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
url4: "http://lesscss.org/hello";
url5: "http://lesscss.org/54.4";

This comment has been minimized.

Copy link
@jamesfoster

jamesfoster May 24, 2011

Contributor

should this be 54.4px?

This comment has been minimized.

Copy link
@clooth

clooth May 24, 2011

Yes.

}
.mix-mul-class {
color: blue;
color: red;
color: blue;
color: orange;
}
12 changes: 12 additions & 0 deletions test/less/strings.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@
@var5: 54.4px;
url5: "http://lesscss.org/@{var5}";
}

// multiple calls with string interpolation

.mix-mul (@a: green) {
color: ~"@{a}";
}
.mix-mul-class {
.mix-mul(blue);
.mix-mul(red);
.mix-mul(blue);
.mix-mul(orange);
}

0 comments on commit 853604a

Please sign in to comment.