# go-slim **Repository Path**: mirrors_mattn/go-slim ## Basic Information - **Project Name**: go-slim - **Description**: Slim Template Engine for golang - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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 Go. ## Features * **Slim-compatible syntax** — indentation-based HTML templating * **Expressions** — arithmetic, comparison (`==`, `!=`, `<`, `>`, `<=`, `>=`), logical (`&&`, `||`, `!`) * **Conditionals** — `if` / `elsif` / `else` / `unless` * **Iteration** — `for` loops over slices, arrays, and channels * **Layouts** — `content_for` / `yield` with `SetLayout`, matching Ruby Slim conventions * **Embedded filesystem** — `ParseFS` for use with `embed.FS` * **String interpolation** — `Hello #{name}` (HTML-escaped), `#{{html}}` (raw) * **Custom renderers** — built-in `javascript:` and `css:` blocks, extensible via `RegisterRenderer` * **Whitespace control** — `>` (outer) and `<` (inner) * **Wrapped attributes** — `div(id="x" class="y")` * **Self-closing tags** — `div/` ## Usage ### Basic ```slim doctype 5 html lang="ja" head meta charset="UTF-8" title body ul - for x in foo li = x ``` ```go tmpl, err := slim.ParseFile("template.slim") if err != nil { log.Fatal(err) } err = tmpl.Execute(os.Stdout, slim.Values{ "foo": []string{"foo", "bar", "baz"}, }) ``` Output: ```html