https://github.com/mattn/go-slim
Slim Template Engine for golang
https://github.com/mattn/go-slim
Last synced: 9 months ago
JSON representation
Slim Template Engine for golang
- Host: GitHub
- URL: https://github.com/mattn/go-slim
- Owner: mattn
- License: mit
- Created: 2016-08-30T15:07:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-08T04:11:26.000Z (about 2 years ago)
- Last Synced: 2025-03-31T17:17:52.151Z (10 months ago)
- Language: Go
- Homepage:
- Size: 126 KB
- Stars: 113
- Watchers: 7
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# go-slim
[](https://github.com/mattn/go-slim/actions?query=workflow%3Atest)
[](https://codecov.io/gh/mattn/go-slim)
[](https://pkg.go.dev/github.com/mattn/go-slim)
[](https://goreportcard.com/report/github.com/mattn/go-slim)
slim template engine for golang
## Features
* Small Virtual Machine
Enough to manipulate object in template. Support Number/String/Function/Array/Map.
* Ruby Like Text Rendering
Support `Hello #{"Golang"}`
## Usage
### Template File
```slim
doctype 5
html lang="ja"
head
meta charset="UTF-8"
title
body
ul
- for x in foo
li = x
```
### Your Code
```go
tmpl, err := slim.ParseFile("template.slim")
if err != nil {
t.Fatal(err)
}
err = tmpl.Execute(os.Stdout, slim.Values{
"foo": []string{"foo", "bar", "baz"},
})
```
### Output
```html
- foo
- bar
- baz
```
## Builtin-Functions
* trim(s)
* to_upper(s)
* to_lower(s)
* repeat(s, n)
## License
MIT
## Author
Yasuhiro Matsumoto (a.k.a. mattn)