juicer 語法

${ 變量 }javascript

處於安全角度考慮 ${ 變量 } 會對內容進行轉義 $${ 變量 }避免轉義html

${ _ } 經常使用於數據源爲數組的狀況 _ 爲對數據源的引用java

${@each} ...{@/each}  循環json

${@if}...{@else if}...{@else}...{@/if}數組

${varname | function }安全

{# 註釋內容}框架

自定義函數函數

var json = {ui

  links: [htm

    { href: 'http://juicer.name' , alt: 'Juicer'},

    { href: 'http://benben.cc', alt: 'Benben'},

    {href: 'http://ued.taobao.com', alt: 'Taobao UED'}  

  ]

};

 

var tpl = [

  '{@each links as item}',

    '${item|links_build} <br />',

  '{@/each}'

].join(' ');

 

var links = function(data) {

  return '<a href=" ' + data.href + ' " alt=" ' + data.alt +  ' ">';

}

juicer.register('links_build', links);

juicer(tpl, json);

 

html 中的模版 和javascript 有相應的對應關係

/*********************************************/

  框架裏的 tr 的id <tr id="object_object->id">

  在juicer 進行數據綁定

  <script type="text/template" id="product_channel_tpl">

    <tr id="product_channel_${product_channel.id}">

    ....    

  </script>

/********************************************/

相關文章
相關標籤/搜索