src/helpers.js
/**
    Interprets `params.val` as a YRB message to format.
    @method formatMessage
    @param {Object} chunk The dust Chunk object.
    @param {Object} context The dust Context object.
    @param {Object} bodies An object containing the dust bodies.
    @param {Object} params An object containing the parameters in the markup for this helper.
    @return {Object} The `chunk` parameter.
    */
Interprets `params.val` as a YRB message to format.
Interprets ` params . val ` as a YRB message to format .
function formatMessage(chunk, context, bodies, params) {
        var formatOptions = {},
            locales,
            msg,
            formatter;
        params = params || {};
        if (params.hasOwnProperty('_msg')) {
            msg = params._msg;
        }
        else if (params._key) {
            msg = contextGet(context, ['intl', 'messages', tap(params._key, chunk, context)]);
        }
        else {
            throw new ReferenceError('@formatMessage needs either a `_msg` or `_key` parameter');
        }
        if ('object' === typeof msg && 'function' === typeof msg.format) {
            chunk.write(msg.format(params));
            return chunk;
        }
        formatOptions = contextGet(context, ['intl', 'formats']);
        locales = getLocales(chunk, params, context);
        formatter = getMessageFormat(msg, locales, formatOptions);
        chunk.write(dust.escapeHtml(formatter.format(params)));
        return chunk;
    }
function formatMessage ( chunk , context , bodies , params ) { var formatOptions = { } , locales , msg , formatter ; params = params || { } ; if ( params . hasOwnProperty ( '_msg' ) ) { msg = params . _msg ; } else if ( params . _key ) { msg = contextGet ( context , [ 'intl' , 'messages' , tap ( params . _key , chunk , context ) ] ) ; } else { throw new ReferenceError ( '@formatMessage needs either a `_msg` or `_key` parameter' ) ; } if ( 'object' === typeof msg && 'function' === typeof msg . format ) { chunk . write ( msg . format ( params ) ) ; return chunk ; } formatOptions = contextGet ( context , [ 'intl' , 'formats' ] ) ; locales = getLocales ( chunk , params , context ) ; formatter = getMessageFormat ( msg , locales , formatOptions ) ; chunk . write ( dust . escapeHtml ( formatter . format ( params ) ) ) ; return chunk ; }
Interprets `params.val` as a YRB message to format.
Interprets ` params . val ` as a YRB message to format .
// optimization for messages that have already been compiled