plugin-set-options-v2.js 715 Bytes
Newer Older
liang ce committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
var optionsStack = [
    'option1',
    undefined,
    'option2',
    undefined,
    'option3'
];

var optionsWereSet = false;
var options, error;

registerPlugin({
    install: function(less, pluginManager, functions) {
        if (!optionsWereSet) {
            error = 'setOptions() not called before install';
        }
    },
    use: function() {
        var pos = optionsStack.indexOf(options);

        if (pos === -1) {
            error = 'setOptions() not setting option "' + opt + '" correctly';
        }
        if (error) {
            throw new Error(error);
        }
    },
    setOptions: function(opts) {
        optionsWereSet = true;
        options = opts;
    },
    minVersion: [2,0,0]
});