<html> <head> <title>邮件标题</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="description" content="alert results." /> <style type="text/css"> body { margin: 10px 20px; font-size: 14px; font-family: "Arial","Microsoft YaHei","黑体","宋体",sans-serif; } /*table*/ /*{*/ /*border-collapse: collapse;*/ /*text-align: center;*/ /*font-size: 14px;*/ /*}*/ /*table td, table th*/ /*{*/ /*border: 2px solid #cc6f4a;*/ /*color: #666;*/ /*height: 20px;*/ /*text-align: center;*/ /*padding: 3px 3px;*/ /*}*/ /*table thead th*/ /*{*/ /**/ /*width: 100px;*/ /*}*/ /*table tr:nth-child(odd)*/ /*{*/ /*background: #fff;*/ /*}*/ /*table tr:nth-child(even)*/ /*{*/ /*background: #c9dafa;*/ /*}*/ .successBtn { width: 60px; padding:3px; background-color: #58ab48; border-color: #58ab48; color: #fff; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; /* future proofing */ -khtml-border-radius: 10px; /* for old Konqueror browsers */ text-align: center; vertical-align: middle; border: 1px solid transparent; font-weight: 500; /*font-size:125%*/ } .failBtn{ width: 60px; padding:3px; background-color: #ab2e2d; border-color: #ab2e2d; color: #fff; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; /* future proofing */ -khtml-border-radius: 10px; /* for old Konqueror browsers */ text-align: center; vertical-align: middle; border: 1px solid transparent; font-weight: 500; /*font-size:125%*/ } </style> <style> /* Border styles */ .tabNoBorder thead, .tabNoBorder tr { border-top-width: 1px; border-top-style: solid; border-top-color: rgb(211, 202, 221); } .tabNoBorder { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(211, 202, 221); } /* Padding and font style */ .tabNoBorder td, .tabNoBorder th { padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121); } /* Alternating background colors */ .tabNoBorder tr:nth-child(even) { background: rgb(223, 216, 232) } .tabNoBorder tr:nth-child(odd) { /*background: #FFF*/ background: rgb(223, 216, 232) } </style> </head> <body> <h2>Summary</h2> <span>预警任务《{{.TaskName}}》警告。 。详情如下:</span> <h2>Detail</h2> <table class="tabNoBorder" style="border-top-width:1px; border-top-color: rgb(211, 202, 221);"> <tr class="columnHeadings" style="border-top-width:1px; border-top-style: solid; border-top-color: rgb(211, 202, 221);background: rgb(223, 216, 232)"> <th style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">详细数据</th> <th style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">对比实际值</th> <th style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">阈值</th> <th style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">对比结果</th> </tr> {{ range $Item := .Data }} {{ range $i,$Item1 := $Item }} {{if eq $i 0}} <tr style="border-top-width:1px; border-top-style: solid; border-top-color: rgb(211, 202, 221);background: rgb(223, 216, 232)"> <td rowspan="{{len $Item}}" style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);"> </td> <td style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">{{$Item1.realValue}}</td> <td style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">{{$Item1.threshold}}</td> <td rowspan="{{len $Item}}" style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);"><div class="failBtn">Alert</div></td> </tr> {{else}} <tr style="border-top-width:1px; border-top-style: solid; border-top-color: rgb(211, 202, 221);background: rgb(223, 216, 232)"> <td style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">{{$Item1.realValue}}</td> <td style="padding: 5px 10px; font-size: 14px; font-family: Verdana; color: rgb(95, 74, 121);">{{$Item1.threshold}}</td> </tr> {{end}} {{end}} {{end}} </table> <br/><br/> </body> </html>
var builtins = FuncMap{
"and": and,
"call": call,
"html": HTMLEscaper,
"index": index,
"js": JSEscaper,
"len": length,
"not": not,
"or": or,
"print": fmt.Sprint,
"printf": fmt.Sprintf,
"println": fmt.Sprintln,
"urlquery": URLQueryEscaper,
// Comparisons
"eq": eq, // ==
"ge": ge, // >=
"gt": gt, // >
"le": le, // <=
"lt": lt, // <
"ne": ne, // !=
}
template内置函数,使用方法为ps: {{printf "%d" var1}}