[Pkg-javascript-commits] [less.js] 104/285: Cleaned up and added iteration for javascript too.
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit a038121676ac06a905324697a8fc5c41f30070fd
Author: jurcovicovam <meri at meri.org>
Date: Fri Sep 5 17:04:06 2014 +0200
Cleaned up and added iteration for javascript too.
---
lib/less/tree/quoted.js | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/lib/less/tree/quoted.js b/lib/less/tree/quoted.js
index da7bc6b..6288d80 100644
--- a/lib/less/tree/quoted.js
+++ b/lib/less/tree/quoted.js
@@ -20,20 +20,24 @@ tree.Quoted.prototype = {
},
toCSS: tree.toCSS,
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 new(tree.JavaScript)(exp, that.index, true).eval(env).value;
- });
- var evaluatedValue = value;
- var interpolationReplacementFnc = function (_, name) {
+ };
+ var interpolationReplacement = function (_, name) {
var v = new(tree.Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
return (v instanceof tree.Quoted) ? v.value : v.toCSS();
};
- do {
- value = evaluatedValue;
- evaluatedValue = value.replace(/@\{([\w-]+)\}/g, interpolationReplacementFnc);
- } while (value!==evaluatedValue);
- value = evaluatedValue;
+ 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(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
},
compare: function (x) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list