//渲染评论HTML代码 func (cl CommentNode) renderItemBegin(b *bytes.Buffer, sortType string) { if cl.Status == 2 { cl.Content = "[已删除]" } b.WriteString(fmt.Sprintf(`<div id="cm-%d" class="cm" data-id="%v"> <div class="vt"> <a class="icon-thumbs-up up" href="javascript:"></a> <a class="icon-thumbs-down down" href="javascript:"></a> </div> <div class="ct"> <div class="uif"> <a class="ep" href="javascript:">[–]</a> <a href="/user/%v">%v</a> <i class="v" title="↑%v ↓%v">%v分</i> <i class="t">%v</i> </div> <div class="tx">%s</div> <div class="ed"> <a href="/link/permacoment/%v/%v/?cm_order=%s" class="cbtn">查看</a> <a href="javascript:" class="cbtn rp">回复</a> </div>`, cl.Id, cl.Id, cl.UserId, cl.UserName, cl.VoteUp, cl.VoteDown, cl.VoteUp-cl.VoteDown, cl.SinceTime(), lib.Markdown([]byte(cl.Content)), //strings.Replace(cl.Content, "\n", "<br/>", -1), cl.LinkId, cl.Id, sortType)) }
// 生成HTML,不包含子评论。 func (c Comment) HtmlContent() template.HTML { html := lib.Markdown([]byte(c.Content)) return template.HTML(html) }