lib/middleware/jng.directives.js
function getGenericDirective(prefix, attrName, filterType, isBind, isFilter) {
    var directiveName = prefix + attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
    var config = this.pancakes.cook('config', null);
    var i18n = this.pancakes.cook('i18n', null);
    var eventBus = this.pancakes.cook('eventBus', null);
    var me = this;

    return function (scope, element, attrs) {
        var originalValue = attrs[directiveName];
        var boundValue = isBind ? me.getNestedValue(scope, originalValue) : originalValue;
        var value = boundValue;
        var useSSL, staticFileRoot, status;

        // if we are using a file filter, add the static file root
        if (isFilter && filterType === 'file' && config && config.staticFiles) {
            useSSL = (config[scope.appName] && config[scope.appName].useSSL !== undefined) ?
                config[scope.appName].useSSL : config.useSSL;
            staticFileRoot = config.staticFiles.assets;
            staticFileRoot = (staticFileRoot.charAt(0) === '/') ? staticFileRoot :
                ((useSSL ? 'https://' : 'http://') + config.staticFiles.assets + '/');
            value = staticFileRoot + value;
        }
        // else for i18n filter, try to translate
        else if (isFilter && filterType === 'i18n' && i18n && i18n.translate) {
            //var cls = require('continuation-local-storage');
            //var session = cls.getNamespace('appSession');
            //var appName = (session && session.active && session.get('app')) || 'contact';
            //var lang = (session && session.active && session.get('lang')) || 'en';

            status = {};
            value = i18n.translate(value, scope, status);

            // this is only done when we are in i18nDebug mode which is used to figure out
            // where we have missing translations
            if (status.missing) {
                eventBus.emit('i18n.missing', {
                    lang:       status.lang,
                    text:       boundValue,
                    appName:    status.app,
                    binding:    originalValue,
                    directive:  directiveName,
                    context:    JSON.stringify(element)
                });
            }
        }

        if (attrName === 'text') {
            element.text(value);
        }
        else if (attrName === 'class') {
            attrs.$addClass(value);
        }
        else {
            value = value ? value.replace(/"/g, '') : value;
            attrs.$set(attrName, value, scope);
        }

        // attrName === 'text' ?
        //     element.text(value) :
        //     attrName === 'class' ?
        //         attrs.$addClass(value) :
        //         attrs.$set(attrName, value, scope);
    };
}
function getGenericDirective(prefix, attrName, filterType, isBind, isFilter) {
    var directiveName = prefix + attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
    var config = this.pancakes.cook('config', null);
    var i18n = this.pancakes.cook('i18n', null);
    var eventBus = this.pancakes.cook('eventBus', null);
    var me = this;

    return function (scope, element, attrs) {
        var originalValue = attrs[directiveName];
        var boundValue = isBind ? me.getNestedValue(scope, originalValue) : originalValue;
        var value = boundValue;
        var useSSL, staticFileRoot, status;

        // if we are using a file filter, add the static file root
        if (isFilter && filterType === 'file' && config && config.staticFiles) {
            useSSL = (config[scope.appName] && config[scope.appName].useSSL !== undefined) ?
                config[scope.appName].useSSL : config.useSSL;
            staticFileRoot = config.staticFiles.assets;
            staticFileRoot = (staticFileRoot.charAt(0) === '/') ? staticFileRoot :
                ((useSSL ? 'https://' : 'http://') + config.staticFiles.assets + '/');
            value = staticFileRoot + value;
        }
        // else for i18n filter, try to translate
        else if (isFilter && filterType === 'i18n' && i18n && i18n.translate) {
            //var cls = require('continuation-local-storage');
            //var session = cls.getNamespace('appSession');
            //var appName = (session && session.active && session.get('app')) || 'contact';
            //var lang = (session && session.active && session.get('lang')) || 'en';

            status = {};
            value = i18n.translate(value, scope, status);

            // this is only done when we are in i18nDebug mode which is used to figure out
            // where we have missing translations
            if (status.missing) {
                eventBus.emit('i18n.missing', {
                    lang:       status.lang,
                    text:       boundValue,
                    appName:    status.app,
                    binding:    originalValue,
                    directive:  directiveName,
                    context:    JSON.stringify(element)
                });
            }
        }

        if (attrName === 'text') {
            element.text(value);
        }
        else if (attrName === 'class') {
            attrs.$addClass(value);
        }
        else {
            value = value ? value.replace(/"/g, '') : value;
            attrs.$set(attrName, value, scope);
        }

        // attrName === 'text' ?
        //     element.text(value) :
        //     attrName === 'class' ?
        //         attrs.$addClass(value) :
        //         attrs.$set(attrName, value, scope);
    };
}
function getGenericDirective ( prefix , attrName , filterType , isBind , isFilter ) { var directiveName = prefix + attrName . substring ( 0 , 1 ) . toUpperCase ( ) + attrName . substring ( 1 ) ; var config = this . pancakes . cook ( 'config' , null ) ; var i18n = this . pancakes . cook ( 'i18n' , null ) ; var eventBus = this . pancakes . cook ( 'eventBus' , null ) ; var me = this ; return function ( scope , element , attrs ) { var originalValue = attrs [ directiveName ] ; var boundValue = isBind ? me . getNestedValue ( scope , originalValue ) : originalValue ; var value = boundValue ; var useSSL , staticFileRoot , status ; // if we are using a file filter, add the static file root if ( isFilter && filterType === 'file' && config && config . staticFiles ) { useSSL = ( config [ scope . appName ] && config [ scope . appName ] . useSSL !== undefined ) ? config [ scope . appName ] . useSSL : config . useSSL ; staticFileRoot = config . staticFiles . assets ; staticFileRoot = ( staticFileRoot . charAt ( 0 ) === '/' ) ? staticFileRoot : ( ( useSSL ? 'https://' : 'http://' ) + config . staticFiles . assets + '/' ) ; value = staticFileRoot + value ; } // else for i18n filter, try to translate else if ( isFilter && filterType === 'i18n' && i18n && i18n . translate ) { //var cls = require('continuation-local-storage'); //var session = cls.getNamespace('appSession'); //var appName = (session && session.active && session.get('app')) || 'contact'; //var lang = (session && session.active && session.get('lang')) || 'en'; status = { } ; value = i18n . translate ( value , scope , status ) ; // this is only done when we are in i18nDebug mode which is used to figure out // where we have missing translations if ( status . missing ) { eventBus . emit ( 'i18n.missing' , { lang : status . lang , text : boundValue , appName : status . app , binding : originalValue , directive : directiveName , context : JSON . stringify ( element ) } ) ; } } if ( attrName === 'text' ) { element . text ( value ) ; } else if ( attrName === 'class' ) { attrs . $addClass ( value ) ; } else { value = value ? value . replace ( / " / g , '' ) : value ; attrs . $set ( attrName , value , scope ) ; } // attrName === 'text' ? //     element.text(value) : //     attrName === 'class' ? //         attrs.$addClass(value) : //         attrs.$set(attrName, value, scope); } ; }
Get a generic directive
@param prefix
@param attrName
@param filterType
@param isBind
@param isFilter
@returns {Function}
Get a generic directive