Export 0.1.45
[framework/web/web-ui-fw.git] / build-tools / lib / less / tree / quoted.js
1 (function (tree) {
2
3 tree.Quoted = function (str, content, escaped, i) {
4     this.escaped = escaped;
5     this.value = content || '';
6     this.quote = str.charAt(0);
7     this.index = i;
8 };
9 tree.Quoted.prototype = {
10     toCSS: function () {
11         if (this.escaped) {
12             return this.value;
13         } else {
14             return this.quote + this.value + this.quote;
15         }
16     },
17     eval: function (env) {
18         var that = this;
19         var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
20             return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
21         }).replace(/@\{([\w-]+)\}/g, function (_, name) {
22             var v = new(tree.Variable)('@' + name, that.index).eval(env);
23             return v.value || v.toCSS();
24         });
25         return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
26     }
27 };
28
29 })(require('less/tree'));