mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user