lib/string/castInterpolate.js
function castInterpolate(template, replacements, options) {
    var matches = template.match(regExp);
    var placeholder;
    var not;

    if (matches) {
        placeholder = matches[1];

        // Check if exists first
        if (mout.object.has(replacements, placeholder)) {
            return mout.object.get(replacements, placeholder);
        }

        // Handle not (!) (note that !foo! is ignored but !foo isn't)
        if (/^!+?[^!]+$/.test(placeholder)) {
            placeholder = placeholder.replace(/!!+/, '');
            not = placeholder.charAt(0) === '!';
            placeholder = not ? placeholder.substr(1) : placeholder;

            if (mout.object.has(replacements, placeholder)) {
                placeholder = mout.object.get(replacements, placeholder);
                return not ? !placeholder : !!placeholder;
            }
        }
    }

    return interpolate(template, replacements, options);
}
function castInterpolate(template, replacements, options) {
    var matches = template.match(regExp);
    var placeholder;
    var not;

    if (matches) {
        placeholder = matches[1];

        // Check if exists first
        if (mout.object.has(replacements, placeholder)) {
            return mout.object.get(replacements, placeholder);
        }

        // Handle not (!) (note that !foo! is ignored but !foo isn't)
        if (/^!+?[^!]+$/.test(placeholder)) {
            placeholder = placeholder.replace(/!!+/, '');
            not = placeholder.charAt(0) === '!';
            placeholder = not ? placeholder.substr(1) : placeholder;

            if (mout.object.has(replacements, placeholder)) {
                placeholder = mout.object.get(replacements, placeholder);
                return not ? !placeholder : !!placeholder;
            }
        }
    }

    return interpolate(template, replacements, options);
}
function castInterpolate ( template , replacements , options ) { var matches = template . match ( regExp ) ; var placeholder ; var not ; if ( matches ) { placeholder = matches [ 1 ] ; // Check if exists first if ( mout . object . has ( replacements , placeholder ) ) { return mout . object . get ( replacements , placeholder ) ; } // Handle not (!) (note that !foo! is ignored but !foo isn't) if ( / ^!+?[^!]+$ / . test ( placeholder ) ) { placeholder = placeholder . replace ( / !!+ / , '' ) ; not = placeholder . charAt ( 0 ) === '!' ; placeholder = not ? placeholder . substr ( 1 ) : placeholder ; if ( mout . object . has ( replacements , placeholder ) ) { placeholder = mout . object . get ( replacements , placeholder ) ; return not ? ! placeholder : ! ! placeholder ; } } } return interpolate ( template , replacements , options ) ; }
String interpolation with casting.
Similar to the normal interpolation but if the template contains only
a token and the value is available, the value will be returned.
This way tokens that have values other than strings will be returned instead.

@param {String} template     The template
@param {Object} replacements The replacements
@param {Object} [options]    The options

@return {Mixed} The interpolated string or the real token value
String interpolation with casting . Similar to the normal interpolation but if the template contains only a token and the value is available the value will be returned . This way tokens that have values other than strings will be returned instead .