ITeye博客

PURE JavaScript模板库的改进

imhades · 2008-09-23 20:36 · HTML · PHP · json · JavaScript · Markdown

来源:OurJS.cn  原文:http://www.ourjs.cn/show.php?id=597

 

  PURE是一个JavaScript的模板引擎。新版本PURE的改进包括:

要了解更多这个库的使用方法,可以查看PURE的官方文档 。

“自动表现(auto-rendering)”例子:

JAVASCRIPT:

  1. $('#hello').autoRender({ "who": "Mary" });}

 

JAVASCRIPT:

  1. button.value = 'loading data...';
  2. var script = (button.id == 'b4_2') ? 'js/jsonBig.js':'js/jsonSmall.js';
  3. $.getJSON(script, function(context){
  4. var directive = {
  5. 'tbody tr td[onclick]':'"clickLine(this)"',
  6. 'tbody tr td[onmouseover]': '"swapStyle(this, true);"',
  7. 'tbody tr td[onmouseout]' : '"swapStyle(this, false);"',
  8. 'tbody tr td[style]':'\'cursor:pointer\'',
  9. 'tbody tr[class]+':
  10. function(context, items, pos){
  11. var oddEven =  (pos % 2 == 0) ? 'even' : 'odd';
  12. var firstLast = (pos == 0) ? 'first': (pos == items.length -1) ? 'last':'';
  13. return oddEven + ' ' + firstLast; }}
  14. $('table.players.2').autoRender(context, directive);
  15. button.value = 'Refresh the page to render again';});}

 来源:OurJS.cn  原文:http://www.ourjs.cn/show.php?id=597

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。