diff options
Diffstat (limited to 'node_modules/stylus/lib/functions/define.js')
| -rw-r--r-- | node_modules/stylus/lib/functions/define.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/stylus/lib/functions/define.js b/node_modules/stylus/lib/functions/define.js new file mode 100644 index 00000000..35b704f6 --- /dev/null +++ b/node_modules/stylus/lib/functions/define.js @@ -0,0 +1,23 @@ +var utils = require('../utils') + , nodes = require('../nodes'); + +/** + * Set a variable `name` on current scope. + * + * @param {String} name + * @param {Expression} expr + * @param {Boolean} [global] + * @api public + */ + +module.exports = function define(name, expr, global){ + utils.assertType(name, 'string', 'name'); + expr = utils.unwrap(expr); + var scope = this.currentScope; + if (global && global.toBoolean().isTrue) { + scope = this.global.scope; + } + var node = new nodes.Ident(name.val, expr); + scope.add(node); + return nodes.null; +}; |
