janl/mustache.js — pull request #140 by thegrandpoobah (2011-11-14 15:10:56+00:00)
Title: Mustache.format

.format is syntactic sugar over the existing to_html function which adds a functionality similar to of the "String.format" from Java/C#. Basically, rather than take named tag keys, it uses numbered tag keys that correspond to the nth argument of the function:

Mustache.format('{{0}} is {{1}}.', 'Mustache', 'awesome'); // ==> 'Mustache is awesome.'

Of course, the full Mustache syntax is available:

Mustache.format('{{#0}}{{1}}{{/0}}.', isColorRed, 'red');

Look at this wiki article for more information: https://github.com/doodads/mustache.js/wiki/API-format

I find this bit of sugar very useful, so I thought I'd spread the love :)

I didn't know how to add unit tests since the test runner always runs against `to_html`. But if you let me know where/how to add them, I'll gladly do so.