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

Related articles

Golang 把cookie 字符串解析为cookie 结构

在做爬虫时有时候会遇到需要带已登录的 cookie 请求,这个时候最简单的方法是在浏览器登录后,在开发者面板找到cookie 字符串,然后拷贝粘贴。这就面临一个问题需要把cookie 字符串解析成Go 语言 cookie 结构体。...

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

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.16.5 Processed in 1ms