var doubleEncode = false;
var _ = {
encode: function(str) {
return str.replace(/&/g,"&").
replace(/</g,"<").
replace(/>/g,">");
},
parseData: function(str) {
return eval('(' + str + ')');
},
el: function(str) {
return document.getElementById(str);
}
};
window.onload = function() {
var template = _.el('tpl_example').innerHTML;
var data = _.parseData(_.el('data').innerHTML);
var output = Templ(template, data);
_.el('template').innerHTML = !doubleEncode ? _.encode(template.replace(/^\n/, '')) : template.replace(/^\n/, '');
_.el('output').innerHTML = !doubleEncode ? _.encode(output.replace(/^\n/, '')) : output.replace(/^\n/, '');
}; |