1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 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; }); |