carto/lib/less/node/rule.js

36 lines
973 B
JavaScript
Raw Normal View History

if (typeof(window) === 'undefined') { var tree = require(require('path').join(__dirname, '..', '..', 'less', 'tree')); }
2010-02-24 02:39:05 +08:00
tree.Rule = function Rule(name, value) {
2010-02-24 02:39:05 +08:00
this.name = name;
this.value = value;
if (name.charAt(0) === '@') {
this.variable = true;
} else { this.variable = false }
};
tree.Rule.prototype.toCSS = function (env) {
2010-02-26 06:56:21 +08:00
if (this.variable) { return "" }
else {
return this.name + ": " +
(this.value.toCSS ? this.value.toCSS(env) : this.value) + ";";
}
2010-02-24 02:39:05 +08:00
};
tree.Value = function Value(value) {
2010-02-24 02:39:05 +08:00
this.value = value;
this.is = 'value';
};
tree.Value.prototype.eval = function (env) {
2010-02-24 02:39:05 +08:00
if (this.value.length === 1) {
return this.value[0].eval(env);
} else {
throw new(Error)("trying to evaluate compound value");
}
};
tree.Value.prototype.toCSS = function (env) {
2010-02-24 02:39:05 +08:00
return this.value.map(function (e) {
return e.toCSS ? e.toCSS(env) : e;
}).join(', ');
};