index.js
function htmlToJsonController (fileContents, filePath, output, p) {

    var matches;
    var includePaths = false;

    while (matches = _DIRECTIVE_REGEX.exec(fileContents)) {

        var relPath     = path.dirname(filePath),
            fullPath    = path.join(relPath,  matches[3].replace(/['"]/g, '')).trim(),
            jsonVar     = matches[2],
            extension   = matches[3].split('.').pop();

        var fileMatches = [];

        if (p.includePaths) {

            if (typeof p.includePaths == "string") {
                // Arrayify the string
                includePaths = [params.includePaths];
            }else if (Array.isArray(p.includePaths)) {
                // Set this array to the includepaths
                includePaths = p.includePaths;
            }

            var includePath = '';

            for (var y = 0; y < includePaths.length; y++) {

                includePath = path.join(includePaths[y], matches[3].replace(/['"]/g, '')).trim();

                if (fs.existsSync(includePath)) {

                    var globResults = glob.sync(includePath, {mark: true});
                    fileMatches = fileMatches.concat(globResults);

                }

            }

        } else {

            var globResults = glob.sync(fullPath, {mark: true});
            fileMatches = fileMatches.concat(globResults);

        }

        try {

            fileMatches.forEach(function(value){

                var _inc = _parse(value);

                if (_inc.length > 0) {

                    var ind = (jsonVar.trim() == '*') ? indName(value) : jsonVar;
                    output[ind] = _inc;
                }
            })

        } catch (err) {
            console.log(err)
        }

    }
}
function htmlToJsonController (fileContents, filePath, output, p) {

    var matches;
    var includePaths = false;

    while (matches = _DIRECTIVE_REGEX.exec(fileContents)) {

        var relPath     = path.dirname(filePath),
            fullPath    = path.join(relPath,  matches[3].replace(/['"]/g, '')).trim(),
            jsonVar     = matches[2],
            extension   = matches[3].split('.').pop();

        var fileMatches = [];

        if (p.includePaths) {

            if (typeof p.includePaths == "string") {
                // Arrayify the string
                includePaths = [params.includePaths];
            }else if (Array.isArray(p.includePaths)) {
                // Set this array to the includepaths
                includePaths = p.includePaths;
            }

            var includePath = '';

            for (var y = 0; y < includePaths.length; y++) {

                includePath = path.join(includePaths[y], matches[3].replace(/['"]/g, '')).trim();

                if (fs.existsSync(includePath)) {

                    var globResults = glob.sync(includePath, {mark: true});
                    fileMatches = fileMatches.concat(globResults);

                }

            }

        } else {

            var globResults = glob.sync(fullPath, {mark: true});
            fileMatches = fileMatches.concat(globResults);

        }

        try {

            fileMatches.forEach(function(value){

                var _inc = _parse(value);

                if (_inc.length > 0) {

                    var ind = (jsonVar.trim() == '*') ? indName(value) : jsonVar;
                    output[ind] = _inc;
                }
            })

        } catch (err) {
            console.log(err)
        }

    }
}
function htmlToJsonController ( fileContents , filePath , output , p ) { var matches ; var includePaths = false ; while ( matches = _DIRECTIVE_REGEX . exec ( fileContents ) ) { var relPath = path . dirname ( filePath ) , fullPath = path . join ( relPath , matches [ 3 ] . replace ( / ['"] / g , '' ) ) . trim ( ) , jsonVar = matches [ 2 ] , extension = matches [ 3 ] . split ( '.' ) . pop ( ) ; var fileMatches = [ ] ; if ( p . includePaths ) { if ( typeof p . includePaths == "string" ) { // Arrayify the string includePaths = [ params . includePaths ] ; } else if ( Array . isArray ( p . includePaths ) ) { // Set this array to the includepaths includePaths = p . includePaths ; } var includePath = '' ; for ( var y = 0 ; y < includePaths . length ; y ++ ) { includePath = path . join ( includePaths [ y ] , matches [ 3 ] . replace ( / ['"] / g , '' ) ) . trim ( ) ; if ( fs . existsSync ( includePath ) ) { var globResults = glob . sync ( includePath , { mark : true } ) ; fileMatches = fileMatches . concat ( globResults ) ; } } } else { var globResults = glob . sync ( fullPath , { mark : true } ) ; fileMatches = fileMatches . concat ( globResults ) ; } try { fileMatches . forEach ( function ( value ) { var _inc = _parse ( value ) ; if ( _inc . length > 0 ) { var ind = ( jsonVar . trim ( ) == '*' ) ? indName ( value ) : jsonVar ; output [ ind ] = _inc ; } } ) } catch ( err ) { console . log ( err ) } } }
Control HTML to JSON
@param fileContents
@param filePath
@param output
@param p
Control HTML to JSON