Skip to content

Commit

Permalink
📝 chore: update README docs and add ci test on go1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Feb 29, 2024
1 parent 8eb9140 commit 16d7c08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: [1.21, 1.19, '1.20']
go_version: [1.21, 1.19, '1.20', 1.22]
os: [ubuntu-latest]

steps:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EasyTpl

[![GoDoc](https://pkg.go.dev/github.com/gookit/easytpl?status.svg)](https://pkg.go.dev/github.com/gookit/easytpl)
[![GoDoc](https://pkg.go.dev/badge/github.com/gookit/easytpl.svg)](https://pkg.go.dev/github.com/gookit/easytpl)
[![Coverage Status](https://coveralls.io/repos/github/gookit/easytpl/badge.svg?branch=master)](https://coveralls.io/github/gookit/easytpl?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/easytpl)](https://goreportcard.com/report/github.com/gookit/easytpl)
[![Unit-Tests](https://github.com/gookit/easytpl/workflows/Unit-Tests/badge.svg)](https://github.com/gookit/easytpl/actions)
Expand Down Expand Up @@ -39,8 +39,8 @@ import (
)

func main() {
// equals to call: easytpl.NewRenderer() + r.MustInitialize()
r := easytpl.NewInitialized(func(r *easytpl.Renderer) {
// equals to call: easytpl.NewRenderer() + r.MustInit()
r := easytpl.NewInited(func(r *easytpl.Renderer) {
// setting default layout
r.Layout = "layout" // equals to "layout.tpl"
// templates dir. will auto load on init.
Expand Down Expand Up @@ -259,7 +259,7 @@ AutoSearchFile bool
r := easytpl.NewRenderer()
r.Layout = "layouts/default"
// ... ...
r.MustInitialize()
r.MustInit()
```

- method 2
Expand All @@ -269,13 +269,13 @@ r := easytpl.NewRenderer(func (r *Renderer) {
r.Layout = "layouts/default"
// ... ...
})
r.MustInitialize()
r.MustInit()
```

- method 3

```go
r := easytpl.NewInitialized(func (r *Renderer) {
r := easytpl.NewInited(func (r *Renderer) {
r.Layout = "layouts/default"
// ... ...
})
Expand Down
18 changes: 9 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# EasyTpl

[![GoDoc](https://pkg.go.dev/github.com/gookit/easytpl?status.svg)](https://pkg.go.dev/github.com/gookit/easytpl)
[![GoDoc](https://pkg.go.dev/badge/github.com/gookit/easytpl.svg)](https://pkg.go.dev/github.com/gookit/easytpl)
[![Coverage Status](https://coveralls.io/repos/github/gookit/easytpl/badge.svg?branch=master)](https://coveralls.io/github/gookit/easytpl?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/easytpl)](https://goreportcard.com/report/github.com/gookit/easytpl)
[![Unit-Tests](https://github.com/gookit/easytpl/workflows/Unit-Tests/badge.svg)](https://github.com/gookit/easytpl/actions)

一个简单的模板渲染器,基于Golang `html/template` 封装,但更加简单易用
简单易用的模板渲染器,基于Golang `html/template` 封装。

> **[EN README](README.md)**
Expand Down Expand Up @@ -35,8 +35,8 @@ import (
)

func main() {
// NewInitialized() 等同于同时调用: easytpl.NewRenderer() + r.MustInitialize()
r := easytpl.NewInitialized(func(r *easytpl.Renderer) {
// NewInited() 等同于同时调用: easytpl.NewRenderer() + r.MustInit()
r := easytpl.NewInited(func(r *easytpl.Renderer) {
// 设置默认布局模板
r.Layout = "layout" // 等同于 "layout.tpl"
// 模板目录。将在初始化是自动加载编译里面的模板文件
Expand Down Expand Up @@ -114,25 +114,25 @@ templates/
</html>
```

- templates/layouts/header.tpl
`templates/layouts/header.tpl` 文件:

```html
<header>
<h2>page header</h2>
</header>
```

- templates/layouts/footer.tpl
`templates/layouts/footer.tpl` 文件:

```html
<footer>
<h2>page footer</h2>
</footer>
```

`templates/home.tpl, templates/about.tpl` 模板文件:
`templates/home.tpl, templates/about.tpl` 页面模板文件:

```html title="home.tpl"
```gotemplate title="home.tpl"
<h1>Hello, {{ .Name | upper }}</h1>
<h2>At template {{ current_tpl }}</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
Expand Down Expand Up @@ -245,7 +245,7 @@ AutoSearchFile bool
- 方法 1

```go
r := easytpl.NewRenderer()
r := easytpl.New()
r.Layout = "layouts/default"
// ... ...
r.MustInit()
Expand Down

0 comments on commit 16d7c08

Please sign in to comment.