An open API service indexing awesome lists of open source software.

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.

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.