https://github.com/karitham/zemplate
Zemplate is a zig templating engine.
https://github.com/karitham/zemplate
Last synced: over 1 year ago
JSON representation
Zemplate is a zig templating engine.
- Host: GitHub
- URL: https://github.com/karitham/zemplate
- Owner: karitham
- License: isc
- Created: 2022-02-24T12:16:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-02T10:09:19.000Z (over 4 years ago)
- Last Synced: 2025-01-22T05:29:47.303Z (over 1 year ago)
- Language: Zig
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zemplate
Zemplate is a *WIP* zig templating engine.
The syntax is inspired by text/template from go.
## Examples
### Identifiers
```txt
{{.foo}}
```
Pulls `foo` from struct and inserts it into the template.
if `foo` is `{ "foo": "bar" }` the output would be
```txt
bar
```
It also works with nested identifiers, `{{.foo.bar}}` with `{ "foo": { "bar": "baz" } }` would output `baz`.
### Ranges
```txt
{{ range .foo }}- {{ .bar }}
{{ end }}
```
if `foo` is `{"foo": [{ "bar": "a" }, { "bar": "b" }, { "bar": "c" }]}` then the output would be
```txt
- a
- b
- c
```
### Conditionals
```txt
{{ if .foo }}{{ .bar }}{{ end }}
```
if `foo` is `{"foo": true, "bar": "hello world!"}` then the output would be
```txt
hello world!
```
## Notes
I'm open to any and all contributions, be it from code-review, documentation or any form of critique, especially since this is my first zig project.