Skip to content

underscore Support #11

@adrianj98

Description

@adrianj98

I have made the lib node/underscore compatible. This is done with little easy but the applyReplacement function has to be change because of the callbacks param order in each. see bottom

this should not brake anything, besides for people that are using jquery and underscore they would have to switch to _ such as _.jsperanto.init

Add to the factory function

if (typeof _ !== 'undefined') {
    // Underscore.
    factory(_);
} else if (typeof exports === 'object') {

removed the call to check if function and did it inline

options = (options == Object(options))? options : callback;

applyReplacement

function applyReplacement(string,replacementHash){
    if ($.ajax === undefined) {
        $.each(replacementHash, function (value, key) {
            string = string.split([o.interpolationPrefix, key, o.interpolationSuffix].join('')).join(value);
        });
    } else {
        $.each(replacementHash, function (key, value) {
            string = string.split([o.interpolationPrefix, key, o.interpolationSuffix].join('')).join(value);
        });
    }
    return string;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions