1 Star 0 Fork 1

Bin/gotemplate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
engine_test.go 443 Bytes
一键复制 编辑 原始数据 按行查看 历史
YouBin 提交于 2025-02-25 17:27 +08:00 . 基本功能补全
package gotemplate
import (
"fmt"
"testing"
)
func main() {
engine := NewTemplateEngine(nil)
template := `
{{
var a = 2
fmt.Println(a)
}}
{{a}} holy
{{ for i := 0; i < 10; i++ }}
{{ if i % 2 == 0 }}
{{i}}-{{i + 1}}
{{ else }}
{{i}}
{{end}}
{{end}}
`
res, _ := engine.Render(template, map[string]interface{}{
"a": 1,
"b": 2,
})
fmt.Println(res)
}
func TestTemplateEngine_Render(t *testing.T) {
main()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/llyb120/gotemplate.git
git@gitee.com:llyb120/gotemplate.git
llyb120
gotemplate
gotemplate
master

搜索帮助