<script id="main_panel_big_sale_template" type="text/html"> {{each products as product i}} {{if i < 3}} <li> <img src="{{product.pictographicIconList[0].image.url | getImageUrl}}" data-imgname="{{product.pictographicIconList[0].image.url}}"> <div class="flash-time-box"> <span>2015-02-09</span> </div> <strong class="marque">{{product.name}}</strong> <strong class="libelle">{{product.description}}</strong> <div class="no-picto"> <span class="prod-tip"> <img src="img/grey.png" data-original="img/icon.png"> </span> <span class="italic black"> <span class="cny-curr">¥ {{product.price.value | formatPrice: 'integer'}}</span><span class="decimal">{{product.price.value | formatPrice: 'decimal'}}</span> </span> </div> </li> {{/if}} {{/each}} </script> JS:template.helper('formatPrice', function(price, type) { if(price){ var arrayPrice = price.toString().split("."); if(type == 'integer') { return arrayPrice[0]?arrayPrice[0]:"0"; }else if (type =='decimal') { return arrayPrice[1]?arrayPrice[1].length == 1?"."+arrayPrice[1]+"0":"."+arrayPrice[1]:".00"; } }else{ if(type == 'integer') { return "0"; }else if (type =='decimal') { return ".00"; } } });
artTemplate的函数使用
最新推荐文章于 2024-04-17 17:54:41 发布