Getting started with doT js templates 3. Getting started with dotjs templates
Determine whether the list of loops is empty before a for Loop
<Script id = "invoiceListDot" type = "text/x-dot-template"> {{? It. invoiceInfoDtos }{{ for (var prop = 0; prop <it. invoiceInfoDtos. length; prop ++) {}}< div class = "{if (prop = 0) {}} invoice-infor {{}else {}} no-invoice {{}} "data-index =" {{= prop }}"> <span class =" no-ivoice-icon "> </span> <span> normal invoice </span> <span class =" ivo-margin ">{{= it. invoiceInfoDtos [prop]. content }}</span> <span class = "ivo-margin" >{{ = it. invoiceInfoDtos [prop]. title }}</span> <span class = "ivo-ma Rgin "> {= it. invoiceInfoDtos [prop]. address }}</span> <span class = "ivo-margin" >{{ = it. invoiceInfoDtos [prop]. extends er }}</span> <span class = "ivo-margin" >{{ = it. invoiceInfoDtos [prop]. phone }}</span> </div> {{}}}{{?}} </Script>
If judgment
<Li class = "company-state"> {{? It. orgAppRelList [I]. expire }{{= it. orgAppRelList [I]. endDate} has expired {{?? }}{{? It. orgAppRelList [I]. isTrial }}enterprises in trial cannot order, <span class = "warning" >{{ = it. orgAppRelList [I]. endTime }}expired </span> {{?? }}{{? It. orgAppRelList [I]. status = '001'} not purchased {{?? It. orgAppRelList [I]. status = '002'} paid {{?? } & Nbsp ;{{= it. orgAppRelList [I]. endDate }}expired {{? }}{{?}} {{?}} </Li>
Macro usage
<Div class = "content" id = "serviceItem"> {{## def. spaceUnit :{{? It. productPrice. policyInfo. storageUnit = 1} K {{?? It. productPrice. policyInfo. storageUnit = 2} M {{?? It. productPrice. policyInfo. storageUnit = 3} G {{??} T {{? }}#}< Div class = "buy-list"> <ul> <li class = "buy-name"> purchase duration: </li> <li class = "buy-select"> <p >{{= it. productPrice. userPeriod} months </p> </li> <li class = "buy-unit"> </li> <li class = "buy-state"> expected expiration time: {= it. productPrice. endTime }}</li> </ul> </div> <div class = "buy-list"> <ul> <li class = "buy-name"> Users: </li> <li class = "buy-select"> <input name = "userCount" onkeypress = "eventUtil. onlyNumberKeyPress (event) "type =" Text "> </li> <li class =" buy-unit "> People </li> <li class =" buy-state "> user unit price {= it. productPrice. normalPriceDto. userPeriodPrice} RMB/person {{? It. productPrice. policyInfoDto. periodUnit = 1} years {{?? It. productPrice. policyInfoDto. periodUnit = 2} month {{?? It. productPrice. policyInfoDto. periodUnit = 3} Days {{??} Unknown organization {{? }}< Span class = "warning"> (currently only teams with less than 200 people are supported) </span> </li> </ul> </div> <div class = "buy-list"> <ul> <li class = "buy-name"> resizing space (all): </li> <li class = "buy-select"> <input name = "expansion_storage" onkeypress = "eventUtil. onlyNumberKeyPress (event) "type =" text "> </li> <li class =" buy-unit ">{{# def. spaceUnit }</li> <li class = "buy-state"> unit price {= it. productPrice. normalPriceDto. storagePrice} RMB/{# def. spaceUnit }}</li> </ul> </div>
Refer:
Getting started with doT js
By Huang Wei (1287789687@qq.com)
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.