Created
March 11, 2014 18:29
-
-
Save Panya/9492012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/nodes/literal.js b/lib/nodes/literal.js | |
index 314329c..84583e7 100644 | |
--- a/lib/nodes/literal.js | |
+++ b/lib/nodes/literal.js | |
@@ -23,6 +23,7 @@ var Literal = module.exports = function Literal(str){ | |
Node.call(this); | |
this.val = str; | |
this.string = str; | |
+ this.prefixed = false; | |
}; | |
/** | |
diff --git a/lib/nodes/string.js b/lib/nodes/string.js | |
index 6a4f508..a051981 100644 | |
--- a/lib/nodes/string.js | |
+++ b/lib/nodes/string.js | |
@@ -25,6 +25,7 @@ var String = module.exports = function String(val, quote){ | |
Node.call(this); | |
this.val = val; | |
this.string = val; | |
+ this.prefixed = false; | |
if (typeof quote !== 'string') { | |
this.quote = "'"; | |
} else { | |
diff --git a/lib/parser.js b/lib/parser.js | |
index 42c15c2..38d6210 100644 | |
--- a/lib/parser.js | |
+++ b/lib/parser.js | |
@@ -1297,7 +1297,9 @@ Parser.prototype = { | |
arr.push(expr); | |
break; | |
case this.prefix && '.': | |
- arr.push(new nodes.Literal(tok.val + this.prefix)); | |
+ var literal = new nodes.Literal(tok.val + this.prefix); | |
+ literal.prefixed = true; | |
+ arr.push(literal); | |
break; | |
case 'comment': | |
arr.push(new nodes.Literal(tok.val.str)); | |
diff --git a/lib/visitor/evaluator.js b/lib/visitor/evaluator.js | |
index 572eef9..a7ce3ff 100644 | |
--- a/lib/visitor/evaluator.js | |
+++ b/lib/visitor/evaluator.js | |
@@ -126,6 +126,7 @@ var Evaluator = module.exports = function Evaluator(root, options) { | |
this.functions = options.functions || {}; | |
this.globals = options.globals || {}; | |
this.paths = options.paths || []; | |
+ this.prefix = options.prefix; | |
this.filename = options.filename; | |
this.includeCSS = options['include css']; | |
this.resolveURL = options['resolve url']; | |
@@ -1348,6 +1349,11 @@ Evaluator.prototype.interpolate = function(node){ | |
return node.name; | |
case 'literal': | |
case 'string': | |
+ if (self.prefix && !node.prefixed && !node.val.nodeName) { | |
+ node.val = node.val.replace(/\./g, '.' + self.prefix); | |
+ node.prefixed = true; | |
+ } | |
+ return node.val; | |
case 'unit': | |
return node.val; | |
case 'expression': |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment