JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgithub.com/janl/mustache.js/master/mustache.js"></script>
<div id='site0'></div>
<div id='site1'></div>
<div id='site2'></div>
<br/>
<div id='chat0'></div>
<div id='chat1'></div>
<div id='chat2'></div>
JavaScript
var json = {
'rows': [],
'numRows': function() {
return this.rows.length
}
} // ajax response data json.
var myTemplate = '{{ numRows }} link{{^rows}}s{{/rows}}{{#rows.1}}s{{/rows.1}} parsed so far.'
json.rows = [];
document.getElementById('site0').innerText = Mustache.to_html(myTemplate, json);
json.rows = ['link1'];
document.getElementById('site1').innerText = Mustache.to_html(myTemplate, json);
json.rows = ['link1', 'link2'];
document.getElementById('site2').innerText = Mustache.to_html(myTemplate, json);
var myTemplate2 = '{{ numRows }} {{^rows}}people{{/rows}}{{#rows.0}}{{^rows.1}}person{{/rows.1}}{{/rows.0}}{{#rows.1}}people{{/rows.1}} joined so far.'
json.rows = [];
document.getElementById('chat0').innerText = Mustache.to_html(myTemplate2, json);
json.rows = ['person1'];
document.getElementById('chat1').innerText = Mustache.to_html(myTemplate2, json);
json.rows = ['person1', 'person2'];
document.getElementById('chat2').innerText = Mustache.to_html(myTemplate2, json);