| 1 |
var plugin = function(options){ |
| 2 |
return function(style){ |
| 3 |
var nodes = this.nodes; |
| 4 |
|
| 5 |
style.define('add', function(a, b) { |
| 6 |
return a.operate('+', b); |
| 7 |
}); |
| 8 |
|
| 9 |
style.define('something', function() { |
| 10 |
return new nodes.Ident('foobar'); |
| 11 |
}); |
| 12 |
|
| 13 |
style.define('set_red', function(color, value) { |
| 14 |
return new nodes.RGBA(value.val, color.g, color.b, color.a); |
| 15 |
}); |
| 16 |
|
| 17 |
style.define('get_opt', function(name) { |
| 18 |
var val = options[name.val]; |
| 19 |
switch (typeof val) { |
| 20 |
case 'boolean': |
| 21 |
return new nodes.Boolean(val); |
| 22 |
case 'number': |
| 23 |
return new nodes.Unit(val); |
| 24 |
case 'string': |
| 25 |
default: |
| 26 |
return new nodes.String(val); |
| 27 |
} |
| 28 |
}); |
| 29 |
}; |
| 30 |
}; |
| 31 |
module.exports = plugin; |