Bootstrap

标题:66666

分类:默认分类, 创建日期:2025-12-21 21:25:21, 更新日期:2025-12-21 21:25:21, 阅读次数:500

<div class="bd-example text-center">
  <table class="table table-hover">
    <thead>
      <tr>
        <th class="border border-secondary border-1" scope="col" style="width: 5%">ID</th>
        <th class="border border-secondary border-1" scope="col" style="width: 10%;">分类</th>
        <th class="border border-secondary border-1" scope="col" style="width: 15%;">创建日期</th>
        <th class="border border-secondary border-1" scope="col" style="width: 15%;">更新日期</th>
      </tr>
    </thead>
    <tbody class="main-text-size">
      <tr class="table-info">
        <td class="border border-secondary border-1">{{.id}}</td>
        <td class="border border-secondary border-1">{{.category}}</td>
        <td class="border border-secondary border-1">{{.created_at}}</td>
        <td class="border border-secondary border-1">{{.updated_at}}</td>
      </tr>
    </tbody>
  </table>

  <!-- 模板还原:直接写{{.content}}即可,不需要任何额外语法 -->
  {{.content}}
</div>

<!-- 可选:样式适配WangEditor(保留) -->
<style>
  img {max-width: 100%; height: auto;}
  table {border-collapse: collapse; width: 100%; margin: 10px 0;}
  table td, table th {border: 1px solid #ddd; padding: 8px;}
</style>
import (
	"html/template" // 只需要导入这个包,不用写任何函数
	// 你的其他依赖:net/http、time等
)

// 准备传递给模板的数据
rss := map[string]any{
	"id":          id,
	"title":       title,
	// 核心修改:这一行把content字符串转为template.HTML类型(只改这1行)
	"content":     template.HTML(content), // 关键:直接转换类型,模板就不会转义了
	"created_at":  created_at.Format("2006-01-02 15:04:05"),
	"updated_at":  updated_at.Format("2006-01-02 15:04:05"),
	"Server_Host": r.Host,
}

// 加载模板文件(你的原有代码,完全不动)
renderTemplate(w, r, "article_view", rss)


Server Information

This is a wider card with supporting text below as a natural lead-in to additional content.

Redis Information

This is a wider card with supporting text below as a natural lead-in to additional content.

Go Gopher climbing a ladder.