doT js 宏的使用
- <script id="serviceItemTemplate" type="text/x-dot-template">
- {{##def.spaceUnit:
- {{? it.policyInfo.storageUnit==1 }}K{{?? it.policyInfo.storageUnit==2}}M{{?? it.policyInfo.storageUnit==3}}G {{?? }}T {{? }}
- #}}
- <div class="buy-list">
- <ul>
- <li class="buy-name">扩容空间(所有):</li>
- <li class="buy-select"><input name="expansion_storage" onkeypress="onlyNumberKeyPress(event)" type="text"></li>
- <li class="buy-unit">{{#def.spaceUnit}}</li>
- <li class="buy-state">空间单价 {{=it.normalPrice.storagePrice}}元/
- {{#def.spaceUnit}}</li>
- </ul>
- </div>
- </script>
其中##def.spaceUnit 就是宏
复杂条件判断
- <script id="orgListTemplate" type="text/x-dot-template">
- {{ for (var i=0;i<it.length;i++){ }}
- <ul class="company-list {{? it[i].selectable }} com-enable{{?? }}com-disable {{? }}" data-orgId="{{=it[i].orgId }}" >
- <li class="choice-box disable"></li>
- <li class="company-name"><span >{{=it[i].orgFullName }}</span></li>
- <li class="company-state">
- {{? it[i].expire }}
- {{=it[i].endTime }}已过期
- {{?? }}
- {{? it[i].isTrial }}
- 试用中的企业无法订购,<span class="warning">{{=it[i].endTime }}过期</span>
- {{?? }}
- {{? it[i].status=='001' }} 未购买{{?? it[i].status=='002'}}已支付 {{?? }}已购买 {{? }}
- {{?}}
- {{?}}
- </li>
- </ul>
- {{ }}}
- </script>