JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.5.0-dev/mustache.min.js"></script>
<script type=text id=tpl>
<ul>
{{#price}}
<li>{{commaFormat}}</li>
{{/price}}
</ul>
</script>
JavaScript
var tpl = $('#tpl').html(),
data = {
price: ['1234', '123', '123456', '1234567890'],
commaFormat: function() {
// adapted from http://stackoverflow.com/questions/2901102/how-to-print-number-with-commas-as-thousands-separators-in-javascript
return this.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
},
html = Mustache.to_html(tpl, data);
document.write(html);