2010-03-13 16:34:48 +08:00
|
|
|
if (typeof(require) !== 'undefined') { var tree = require('less/tree') }
|
2010-03-02 04:32:21 +08:00
|
|
|
|
|
|
|
tree.Variable = function Variable(name) { this.name = name };
|
|
|
|
tree.Variable.prototype = {
|
2010-03-12 04:36:50 +08:00
|
|
|
toCSS: function (env) { return this.eval(env).toCSS(env) },
|
2010-02-26 06:57:47 +08:00
|
|
|
eval: function (env) {
|
2010-04-24 05:52:36 +08:00
|
|
|
var variable, v, name = this.name;
|
2010-02-24 02:39:05 +08:00
|
|
|
|
2010-03-27 14:26:55 +08:00
|
|
|
if (variable = tree.find(env.frames, function (frame) {
|
2010-04-24 05:52:36 +08:00
|
|
|
if (v = frame.variables(name)) {
|
|
|
|
return v.value.eval(env);
|
|
|
|
}
|
2010-03-08 12:33:26 +08:00
|
|
|
})) { return variable }
|
|
|
|
else {
|
|
|
|
throw new(Error)("variable " + this.name + " is undefined");
|
2010-02-24 02:39:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|