src/ConfigParser/ConfigParser.js
function (attributes, variables) {
        if (!attributes && !attributes.name) return;
        var el = new et.Element('plugin');
        el.attrib.name = attributes.name;
        if (attributes.spec) {
            el.attrib.spec = attributes.spec;
        }

        // support arbitrary object as variables source
        if (variables && typeof variables === 'object' && !Array.isArray(variables)) {
            variables = Object.keys(variables)
            .map(function (variableName) {
                return {name: variableName, value: variables[variableName]};
            });
        }

        if (variables) {
            variables.forEach(function (variable) {
                el.append(new et.Element('variable', { name: variable.name, value: variable.value }));
            });
        }
        this.doc.getroot().append(el);
    }
function (attributes, variables) {
        if (!attributes && !attributes.name) return;
        var el = new et.Element('plugin');
        el.attrib.name = attributes.name;
        if (attributes.spec) {
            el.attrib.spec = attributes.spec;
        }

        // support arbitrary object as variables source
        if (variables && typeof variables === 'object' && !Array.isArray(variables)) {
            variables = Object.keys(variables)
            .map(function (variableName) {
                return {name: variableName, value: variables[variableName]};
            });
        }

        if (variables) {
            variables.forEach(function (variable) {
                el.append(new et.Element('variable', { name: variable.name, value: variable.value }));
            });
        }
        this.doc.getroot().append(el);
    }
function ( attributes , variables ) { if ( ! attributes && ! attributes . name ) return ; var el = new et . Element ( 'plugin' ) ; el . attrib . name = attributes . name ; if ( attributes . spec ) { el . attrib . spec = attributes . spec ; } // support arbitrary object as variables source if ( variables && typeof variables === 'object' && ! Array . isArray ( variables ) ) { variables = Object . keys ( variables ) . map ( function ( variableName ) { return { name : variableName , value : variables [ variableName ] } ; } ) ; } if ( variables ) { variables . forEach ( function ( variable ) { el . append ( new et . Element ( 'variable' , { name : variable . name , value : variable . value } ) ) ; } ) ; } this . doc . getroot ( ) . append ( el ) ; }
Adds a plugin element. Does not check for duplicates.
@name addPlugin
@function
@param {object} attributes name and spec are supported
@param {Array|object} variables name, value or arbitary object
Adds a plugin element . Does not check for duplicates .