Is it possible to do this with Mustache.js?
var data = {\"val\":\"3\"},
template = \'
if you do not want to modify the array or DOM tree afterwards you can use a function:
var selval=3; // select 3
var template = '';
var data={
options: [
{val: 1, txt: 'one'},
{val: 2, txt: 'two'},
{val: 3, txt: 'three'}
],
selected: function() {
if (this.val==selval) return "selected";
return "";
}
};
var html = Mustache.to_html(template, data);