bin/lmd_builder.js
function (optionName, isApply, isInline) {
        // /*if ($P.CSS || $P.JS || $P.ASYNC) {*/
        var inlinePreprocessorBlock = isInline ? '/*if (' + optionName + ') {*/' : 'if (' + optionName + ') {',
            bracesCounter = 0,

            startIndex = lmd_js.indexOf(inlinePreprocessorBlock),
            startLength = inlinePreprocessorBlock.length,

            endIndex = startIndex + inlinePreprocessorBlock.length,
            endLength = isInline ? 5 : 1;

        if (startIndex === -1) {
            return false;
        }

        // lookup for own }
        while (lmd_js.length > endIndex) {
            if (lmd_js[endIndex] === '{') {
                bracesCounter++;
            }
            if (lmd_js[endIndex] === '}') {
                bracesCounter--;
            }
            
            // found!
            if (bracesCounter === -1) {
                if (isInline) {
                    // step back
                    endIndex -= 2;
                } else {
                    // remove leading spaces from open part
                    while (startIndex) {
                        startIndex--;
                        startLength++;
                        if (lmd_js[startIndex] !== '\t' && lmd_js[startIndex] !== ' ') {
                            startIndex++;
                            startLength--;
                            break;
                        }
                    }

                    // remove leading spaces from close part
                    while (endIndex) {
                        endIndex--;
                        endLength++;
                        if (lmd_js[endIndex] !== '\t' && lmd_js[endIndex] !== ' ') {
                            endIndex++;
                            endLength--;
                            break;
                        }
                    }
                    // add front \n
                    endLength++;
                    startLength++;
                }

                if (isApply) {
                    // wipe preprocessor blocks only
                    // open
                    lmd_js = lmd_js.substr(0, startIndex) + lmd_js.substr(startIndex + startLength);

                    // close
                    lmd_js = lmd_js.substr(0, endIndex - startLength) + lmd_js.substr(endIndex + endLength - startLength);

                    if (!isInline) {
                        // indent block back
                        var blockForIndent = lmd_js.substr(startIndex, endIndex - startLength - startIndex);

                        blockForIndent = blockForIndent
                            .split('\n')
                            .map(function (line) {
                                return line.replace(/^\s{4}/, '');
                            })
                            .join('\n');

                        lmd_js = lmd_js.substr(0, startIndex) + blockForIndent + lmd_js.substr(endIndex - startLength);
                    }
                } else {
                    // wipe all
                    lmd_js = lmd_js.substr(0, startIndex) + lmd_js.substr(endIndex + endLength);
                }
                break;
            }
            endIndex++;
        }

        return true;
    }
function (optionName, isApply, isInline) {
        // /*if ($P.CSS || $P.JS || $P.ASYNC) {*/
        var inlinePreprocessorBlock = isInline ? '/*if (' + optionName + ') {*/' : 'if (' + optionName + ') {',
            bracesCounter = 0,

            startIndex = lmd_js.indexOf(inlinePreprocessorBlock),
            startLength = inlinePreprocessorBlock.length,

            endIndex = startIndex + inlinePreprocessorBlock.length,
            endLength = isInline ? 5 : 1;

        if (startIndex === -1) {
            return false;
        }

        // lookup for own }
        while (lmd_js.length > endIndex) {
            if (lmd_js[endIndex] === '{') {
                bracesCounter++;
            }
            if (lmd_js[endIndex] === '}') {
                bracesCounter--;
            }
            
            // found!
            if (bracesCounter === -1) {
                if (isInline) {
                    // step back
                    endIndex -= 2;
                } else {
                    // remove leading spaces from open part
                    while (startIndex) {
                        startIndex--;
                        startLength++;
                        if (lmd_js[startIndex] !== '\t' && lmd_js[startIndex] !== ' ') {
                            startIndex++;
                            startLength--;
                            break;
                        }
                    }

                    // remove leading spaces from close part
                    while (endIndex) {
                        endIndex--;
                        endLength++;
                        if (lmd_js[endIndex] !== '\t' && lmd_js[endIndex] !== ' ') {
                            endIndex++;
                            endLength--;
                            break;
                        }
                    }
                    // add front \n
                    endLength++;
                    startLength++;
                }

                if (isApply) {
                    // wipe preprocessor blocks only
                    // open
                    lmd_js = lmd_js.substr(0, startIndex) + lmd_js.substr(startIndex + startLength);

                    // close
                    lmd_js = lmd_js.substr(0, endIndex - startLength) + lmd_js.substr(endIndex + endLength - startLength);

                    if (!isInline) {
                        // indent block back
                        var blockForIndent = lmd_js.substr(startIndex, endIndex - startLength - startIndex);

                        blockForIndent = blockForIndent
                            .split('\n')
                            .map(function (line) {
                                return line.replace(/^\s{4}/, '');
                            })
                            .join('\n');

                        lmd_js = lmd_js.substr(0, startIndex) + blockForIndent + lmd_js.substr(endIndex - startLength);
                    }
                } else {
                    // wipe all
                    lmd_js = lmd_js.substr(0, startIndex) + lmd_js.substr(endIndex + endLength);
                }
                break;
            }
            endIndex++;
        }

        return true;
    }
function ( optionName , isApply , isInline ) { // /*if ($P.CSS || $P.JS || $P.ASYNC) {*/ var inlinePreprocessorBlock = isInline ? '/*if (' + optionName + ') {*/' : 'if (' + optionName + ') {' , bracesCounter = 0 , startIndex = lmd_js . indexOf ( inlinePreprocessorBlock ) , startLength = inlinePreprocessorBlock . length , endIndex = startIndex + inlinePreprocessorBlock . length , endLength = isInline ? 5 : 1 ; if ( startIndex === - 1 ) { return false ; } // lookup for own } while ( lmd_js . length > endIndex ) { if ( lmd_js [ endIndex ] === '{' ) { bracesCounter ++ ; } if ( lmd_js [ endIndex ] === '}' ) { bracesCounter -- ; } // found! if ( bracesCounter === - 1 ) { if ( isInline ) { // step back endIndex -= 2 ; } else { // remove leading spaces from open part while ( startIndex ) { startIndex -- ; startLength ++ ; if ( lmd_js [ startIndex ] !== '\t' && lmd_js [ startIndex ] !== ' ' ) { startIndex ++ ; startLength -- ; break ; } } // remove leading spaces from close part while ( endIndex ) { endIndex -- ; endLength ++ ; if ( lmd_js [ endIndex ] !== '\t' && lmd_js [ endIndex ] !== ' ' ) { endIndex ++ ; endLength -- ; break ; } } // add front \n endLength ++ ; startLength ++ ; } if ( isApply ) { // wipe preprocessor blocks only // open lmd_js = lmd_js . substr ( 0 , startIndex ) + lmd_js . substr ( startIndex + startLength ) ; // close lmd_js = lmd_js . substr ( 0 , endIndex - startLength ) + lmd_js . substr ( endIndex + endLength - startLength ) ; if ( ! isInline ) { // indent block back var blockForIndent = lmd_js . substr ( startIndex , endIndex - startLength - startIndex ) ; blockForIndent = blockForIndent . split ( '\n' ) . map ( function ( line ) { return line . replace ( / ^\s{4} / , '' ) ; } ) . join ( '\n' ) ; lmd_js = lmd_js . substr ( 0 , startIndex ) + blockForIndent + lmd_js . substr ( endIndex - startLength ) ; } } else { // wipe all lmd_js = lmd_js . substr ( 0 , startIndex ) + lmd_js . substr ( endIndex + endLength ) ; } break ; } endIndex ++ ; } return true ; }
Applies or removes block from lmd_js

@param {String} optionName block name eg $P.CACHE
@param isApply  apply or remove block
@param isInline block is inline (based on block comment)

@returns {Boolean} true if block was found, false - not found
Applies or removes block from lmd_js