carto/lib/less/node/rule.js
cloudhead 5ee0209e8a don't use Usage: node [options] script.js [arguments]
-v, --version      print node's version
  --debug[=port]     enable remote debugging via given TCP port
  --debug-brk[=port] as above, but break in node.js and
                     wait for remote debugger to connect
  --cflags           print pre-processor and compiler flags
  --v8-options       print v8 command line options

Documentation can be found at http://nodejs.org/api.html or with 'man node', as it's, um, used by node. Use  instead. Also moved tree.node requires in tree.js
2010-03-01 15:32:21 -05:00

36 lines
973 B
JavaScript

if (typeof(window) === 'undefined') { var tree = require(require('path').join(__dirname, '..', '..', 'less', 'tree')); }
tree.Rule = function Rule(name, value) {
this.name = name;
this.value = value;
if (name.charAt(0) === '@') {
this.variable = true;
} else { this.variable = false }
};
tree.Rule.prototype.toCSS = function (env) {
if (this.variable) { return "" }
else {
return this.name + ": " +
(this.value.toCSS ? this.value.toCSS(env) : this.value) + ";";
}
};
tree.Value = function Value(value) {
this.value = value;
this.is = 'value';
};
tree.Value.prototype.eval = function (env) {
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) {
return this.value.map(function (e) {
return e.toCSS ? e.toCSS(env) : e;
}).join(', ');
};