var TemplateEngine = function(html, options) {
var re = /<%([^%>]+)?%>/g, reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
}
while(match = re.exec(html)) {
add(html.slice(cursor, match.index))(match[1], true);
cursor = match.index + match[0].length;
}
add(html.substr(cursor, html.length - cursor));
code += 'return r.join("");';
return new Function(code.replace(/[\r\t\n]/g, '')).apply(options);
}</%([^%>

 

最新文章

  1. A new comer playing with Raspberry Pi 3B
  2. blade and soul factions
  3. android Java BASE64编码和解码一:基础
  4. 浅谈URLEncoder编码算法
  5. each的用法
  6. Android 进入页面默认定位到ListView的解决方法
  7. Sublime Text 3插件之SublimeTmpl:新建文件的模版插件
  8. 【libsvm学习】
  9. 巧用MySQL之Explain进行数据库优化
  10. Android 读取手机短信
  11. 怎样让HTML5调用手机摄像头拍照——实践就是一切
  12. Android 开发 AirPlay Server
  13. GDI+: Curved Shapes
  14. ios崩溃日志1
  15. js的this作用域
  16. 解决Ubuntu 16.04 上Android Studio2.3上面运行APP时提示DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs的问题
  17. Camtasia Studio CamStudio如何不录制鼠标
  18. ipad开发小结
  19. 启动Tomcat报错:class path resource cannot be opened
  20. postgresql----继承表INHERITS PARENT TABLE

热门文章

  1. python多进程程序之间交换数据的两种办法--Queue和Pipe
  2. JavaScript - call(this)
  3. js 节点 document html css 表单节点操作
  4. [转]svn常用命令
  5. &quot;Project facet Java version 1.7 is not supported&quot;的问题解决的办法
  6. hdu 3183(贪心)
  7. kylin cube测试时,报错:org.apache.hadoop.security.AccessControlException: Permission denied: user=root, access=WRITE, inode=&quot;/user&quot;:hdfs:supergroup:drwxr-xr-x
  8. 快速幂 fast_exp
  9. 创建一个Portlet工程
  10. DSP using MATLAB 随书示例Example2.8