Hello,mynameis<%name%>.I\'m<%age%>yearsold.
';5.console.log(TemplateEngine(template,{6.name:"Krasimir",7.age:298.}));�������������������������������������������1.Hello,mynameisKrasimir.I'm29yearsold.
�����������������������������������������������������������������������������1.varre=/<%([^%>]+)?%>/g;�������������<%����%>�����������g�global����������������������Javascript�������������������������������������������������exec����1.varre=/<%([^%>]+)?%>/g;2.varmatch=re.exec(tpl);�����console.log���match�����������1.[2."<%name%>",3."name",4.index:21,5.input:6."Hello,mynameis<%name%>.I\'m<%age%>yearsold.
"7.]������������������������������while������������������������1.varre=/<%([^%>]+)?%>/g;2.while(match=re.exec(tpl)){3.console.log(match);4.}�����������������<%name%>��<%age%>��������������������������������������������������������������replace�������������1.varTemplateEngine=function(tpl,data){2.varre=/<%([^%>]+)?%>/g;3.while(match=re.exec(tpl)){4.tpl=tpl.replace(match[0],data[match[1]])5.}6.returntpl;7.}����������������������data["property"]����������������������������������������������������data���1.{2.name:"KrasimirTsonev",3.profile:{age:29}4.}�����������������������<%profile.age%>����������data[‘profile.age’]����undefined������������replace�����������������<%�%>������Javascript����������������������������1.vartemplate='Hello,mynameis<%this.name%>.I\'m<%this.profile.age%>yearsold.
';�����������������John���newFunction��������������������������1.varfn=newFunction("arg","console.log(arg+1);");2.fn(2);//outputs3fn������������������������console.log(arg+1);��������������1.varfn=function(arg){2.console.log(arg+1);3.}4.fn(2);//outputs3������...1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。
碎片内容