if("undefined"==typeof OGX)var OGX=function(){};OGX.Templater=function(){},OGX.Templater.templatize=function(__obj,__template){"use strict";function evalOp(__op){var reg=new RegExp("\\@","g");return __op=__op.replace(reg,"__obj."),eval(__op),!0}function extractOps(){var op,e,html,prop,temp,ver,reg=new RegExp("\\$\\(loop ([^(]*)\\)","gi"),match=reg.exec(__template);if(match&&(op=match[1].substr(1).split(" "),prop=op.shift(),temp=op.join(" "),ver=eval("__obj."+prop))){html="";for(var i=0;i<ver.length;i++)html+=temp.replace(".$.","["+i+"].");__template=__template.replace(match[0],html)}if(reg=new RegExp("\\$\\([^(]*\\)","g"),match=__template.match(reg))for(var i=0;i<match.length;i++)e=match[i].substr(1),__template=__template.replace(match[i],""),evalOp(e)}function replaceVals(){for(var reg=new RegExp('["\\>]{1}\\$([^"\\<\\> ]*)["\\<]{1}',"g"),match=__template.match(reg),m,val,pre,post,i=0;i<match.length;i++)pre=match[i].substring(0,1),post=match[i].substr(match[i].length-1,1),m=match[i].substr(1),m=m.substr(0,m.length-1),val=eval(m.replace("$","__obj.")),__template=__template.replace(match[i],pre+val+post)}return extractOps(),replaceVals(),__template};
if("undefined"==typeof OGX)var OGX=function(){};OGX.Templater=function(){},OGX.Templater.templatize=function(__obj,__template){"use strict";function evalOp(__op){var reg=new RegExp("\\@","g");return __op=__op.replace(reg,"__obj."),eval(__op),!0}function extractOps(){var op,e,html,prop,temp,ver,reg=new RegExp("\\$\\(loop ([^(]*)\\)","gi"),match=__template.match(reg);if(match)for(var j=0;j<match.length;j++)if(op=match[j].substr(1).split(" "),op.shift(),prop=op.shift().substr(1),temp=op.join(" "),temp=temp.substring(0,temp.length-1),ver=eval("__obj."+prop)){html="";for(var i=0;i<ver.length;i++)html+=temp.replace(".$.","["+i+"].");__template=__template.replace(match[j],html)}if(reg=new RegExp("\\$\\([^(]*\\)","g"),match=__template.match(reg))for(var i=0;i<match.length;i++)e=match[i].substr(1),__template=__template.replace(match[i],""),evalOp(e)}function replaceVals(){console.log("is now",__template);for(var reg=new RegExp('["\\>]{1}\\$([^"\\<\\> ]*)["\\<]{1}',"g"),match=__template.match(reg),m,val,pre,post,i=0;i<match.length;i++)pre=match[i].substring(0,1),post=match[i].substr(match[i].length-1,1),m=match[i].substr(1),m=m.substr(0,m.length-1),val=eval(m.replace("$","__obj.")),__template=__template.replace(match[i],pre+val+post)}return extractOps(),replaceVals(),__template};
Fix multiple operations