Merge branch 'iterated-interpolation-2094' of github.com:SomMeri/less-rhino.js into 2_0_0

Conflicts:
	lib/less/tree/quoted.js
This commit is contained in:
Luke Page
2014-09-06 14:39:32 +01:00
3 changed files with 43 additions and 4 deletions

View File

@@ -21,13 +21,24 @@ Quoted.prototype.genCSS = function (env, output) {
}
};
Quoted.prototype.eval = function (env) {
var that = this;
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
var that = this, value = this.value;
var javascriptReplacement = function (_, exp) {
return String(that.evaluateJavaScript(exp, env));
}).replace(/@\{([\w-]+)\}/g, function (_, name) {
};
var interpolationReplacement = function (_, name) {
var v = new(Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
return (v instanceof Quoted) ? v.value : v.toCSS();
});
};
function iterativeReplace(value, regexp, replacementFnc) {
var evaluatedValue = value;
do {
value = evaluatedValue;
evaluatedValue = value.replace(regexp, replacementFnc);
} while (value!==evaluatedValue);
return evaluatedValue;
}
value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
value = iterativeReplace(value, /@\{([\w-]+)\}/g, interpolationReplacement);
return new(Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
};
Quoted.prototype.compare = function (other) {