artTemplate 模板引擎

{{each list as value i}}  //  list 变量(如果传递进来的是对象,则是其对象下面的属性值)  value:值  i:序列。固定位置

  <li>{{value}}</li>

{{/each}}

 

{{each list}}

  <li>{{$value}}</li>  //  默认

{{/each}}

 

//  js 中导入模板

arrangeList = '{{each Messages}}'+
                '<div class="div_tr">'+
                    '<div class="a_title"></div>'+
                    '<div class="a_content newcontent_y">'+
                        '<p>【{{$value.title}}】</p>'+
                        '<p>{{$value.content}}</p>'+
                        '<div class="a_datetime">{{$value.updatedWhen}}</div>'+
                        '{{if $value.read == "false"}}'+
                            '<div class="unread"></div>'+
                        '{{/if}}'+
                    '</div>'+
                '</div>'+
        '{{/each}}';
 
arrangeList = template.compile(arrangeList);
arrangeList = arrangeList(res);
 
//  
posted @ 2017-05-15 15:43  一只咸鱼咸鱼  阅读(253)  评论(0编辑  收藏  举报