Code coverage report for string/interpolate.js

Statements: 100% (9 / 9)      Branches: 100% (4 / 4)      Functions: 100% (4 / 4)      Lines: 100% (8 / 8)     

All files » string/ » interpolate.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191   1         1 10 10 16   10     1      
define(['../lang/toString'], function(toString) {
 
    var stache = /\{\{(\w+)\}\}/g; //mustache-like
 
    /**
     * String interpolation
     */
    function interpolate(template, replacements, syntax){
        template = toString(template);
        var replaceFn = function(match, prop){
            return (prop in replacements)? toString(replacements[prop]) : '';
        };
        return template.replace(syntax || stache, replaceFn);
    }
 
    return interpolate;
 
});