. template{Border-bottom:1px solid black;}</style><body> <div id= "container" ></div><!--template--><script type= "text/html" id= " Template "> <div class=" template "> Name:{{name}}</div> <div class=" template "> Age: {{Age}}</div > </script><script type= "Text/javascript" >varperson =function(name, age) { This. Name =name; This. Age =Age ;}varpersons = [NewPerson (' lay ', 23),NewPerson (' Marry ', 24)]varRender =function(HTML, data) {if(DatainstanceofArray) { varTPL =html; HTML= ""; for(vari = 0; i < data.length; i++) { varitem =Data[i]; varTemplate =TPL; varnewhtml =gethtml (template, item); HTML+=newhtml; }; } Else if(typeof(data) = = ' object ') {HTML=gethtml (HTML, data); }; returnhtml;}vargethtml =function(HTML, data) {vararr = Html.match (/{{[a-za-z0-9]+}}/g); for(vari = 0; i < arr.length; i++) { varitem =Arr[i]; varFieldName = Item.replace (/{{/g, "). Replace (/}}/g,"); varValue =Data[fieldname]; HTML=html.replace (Item,value)}; returnhtml;}varTemplate = document.getElementById ("template");varcontainer = document.getElementById ("Container"); container.innerhtml=render (template.innerhtml, persons);</script></body>Script Simple HTML Template implementation