carto/lib/less/node/expression.js

19 lines
529 B
JavaScript
Raw Normal View History

2010-02-24 02:39:05 +08:00
node.Expression = function Expression(value) { this.value = value };
node.Expression.prototype.eval = function (env) {
if (this.value.length > 1) {
throw new(Error)("can't eval compound expression");
} else {
return this.value[0].eval(env);
}
};
node.Expression.prototype.toCSS = function (env) {
var evaled;
evaled = this.value.map(function (e) {
if (e.eval) {
e = e.eval(env);
}
return e.toCSS ? e.toCSS(env) : e;
});
return evaled.join(' ');
};