Browse Source

Add format sugar function.

tags/0.5.2-vsc
Sahab Yazdani 14 years ago
parent
commit
5c0b312438
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      mustache.js

+ 13
- 0
mustache.js View File

@@ -667,6 +667,19 @@ var Mustache = (function(undefined) {
return result;
}
},
format: function(template/*, args */) {
var program = Mustache.compile(template),
args = Array.prototype.slice.call(arguments),
view = {};
args.shift();
for (var i = 0, n = args.length; i < n; ++i) {
view['' + i] = args[i];
}
return program(view);
},

Error: MustacheError
});


Loading…
Cancel
Save