format.js 355 B

1234567891011
  1. define(function(require, exports, module) {
  2. function format(template, args) {
  3. if (typeof(args) != 'object') {
  4. args = [].slice.call(arguments, 1);
  5. }
  6. return String(template).replace(/\{(\w+)\}/ig, function(match, $key) {
  7. return args[$key] || $key;
  8. });
  9. }
  10. return module.exports = format;
  11. });