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 生成防识别的图片验证码

验证码 captcha 是对抗密码强力破解、垃圾信息的有效方式,一般用于用户注册、登录,当检测到频繁发帖时也会启用验证码。下面介绍用golang 生成防机器识别的图片验证码。...

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

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