GolangNote

Golang笔记

ace: 类似Markdown 风格的Golang HTML template

Permalink

yosssi/ace 基于 html/template 包实现的模版引擎,模版风格类似Markdown,还能缓存渲染结果。

go ace 模版引擎

ace 示例

plaintext: ace 示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
= doctype html
html lang=en
  head
    title Hello Ace
    = css
      h1 { color: blue; }
  body
    h1 {{.Msg}}
    #container.wrapper
      p..
        Ace is an HTML template engine for Go.
        This engine simplifies HTML coding in Go web application development.
    = javascript
      console.log('Welcome to Ace');

输出是这样:

HTML: 模版输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello Ace</title>
    <style type="text/css">
      h1 { color: blue; }
    </style>
  </head>
  <body>
    <h1>Hello Ace</h1>
    <div id="container" class="wrapper">
      <p>
        Ace is an HTML template engine for Go.<br>
        This engine simplifies HTML coding in Go web application development.
      </p>
    </div>
    <script type="text/javascript">
      console.log('Welcome to Ace');
    </script>
  </body>
</html>

yosssi/ace 项目地址 https://github.com/yosssi/ace

本文网址: https://golangnote.com/topic/19.html 转摘请注明来源

Related articles

谷歌翻译的 golang 库推荐

Google 的翻译越来越好了,官方的Golang SDK 已经很完美,这里介绍的是几个非官方发布的有特色的库。...

Golang 时区时差处理方式

个人习惯用 0 时区时间戳记录时间,可以方便转到不同时区,下面介绍 Golang 时区时差处理...

Write a Comment to "ace: 类似Markdown 风格的Golang HTML template"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 0ms