读书人

javascript模板发动机PURE

发布时间: 2012-11-25 11:44:31 作者: rapoo

javascript模板引擎PURE
现在有许多javascript模板引擎和服务器端的freemarker那些很像,定义模板像下面:

<textarea id="template" style="display:none">    <strong>{$T.name} : {$T.list_id}</strong>    <table>      <tr>        <th>编号</th>        <th>姓名</th>        <th>年龄</th>        <th>邮箱</th>      </tr>      {#foreach $T.table as record}      <tr>        <td>{$T.record.id}</td>        <td>{$T.record.name}</td>        <td>{$T.record.age}</td>        <td>{$T.record.mail}</td>      </tr>      {#/for}     </table>  </textarea> 
感觉对html改动较大,pure就不一样了,对美工做的html影响很小。看下面一个例子:
<html><head><title>PURE Unobtrusive Rendering Engine</title><script src="../libs/jquery.js"></script><script src="../libs/pure.js"></script>  <style>    .even td { background : #DDD }    .odd  td { background : #FFF }  </style></head><body><div style="width:100%; height: 288px; overflow: auto;"><!-- HTML 模板 --><table id="mytb1" width="100%" border="0" cellspacing="0" cellpadding="0">  <tr onmouseover="$(this).addClass('highlight');" onmouseout="$(this).removeClass('highlight');"><td width="25%" />  

读书人网 >JavaScript

热点推荐