Code coverage report for string/interpolate.js

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

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 6 14   6     1      
define(function () {
 
    var stache = /\{\{(\w+)\}\}/g; //mustache-like
 
    /**
     * String interpolation
     * @version 0.1.0 (2012/03/05)
     */
    function interpolate(template, replacements, syntax){
        var replaceFn = function(match, prop){
            return (prop in replacements)? replacements[prop] : '';
        };
        return template.replace(syntax || stache, replaceFn);
    }
 
    return interpolate;
 
});