mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
feat: Added mustache templating.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
Hello, {{name}}!
|
||||
|
||||
Languages you know:
|
||||
{{#languages}}
|
||||
- {{.}}
|
||||
{{/languages}}
|
||||
|
||||
{{#show_footer}}
|
||||
---
|
||||
Rendered with odin-mustache.
|
||||
{{/show_footer}}
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
import mustache "../.."
|
||||
|
||||
Person :: struct {
|
||||
name: string,
|
||||
languages: []string,
|
||||
show_footer: bool,
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
data := Person{
|
||||
name = "World",
|
||||
languages = {"Odin", "C", "Rust"},
|
||||
show_footer = true,
|
||||
}
|
||||
|
||||
result, err := mustache.render_from_filename("hello.mustache", data)
|
||||
if err != nil {
|
||||
fmt.eprintfln("render error: %v", err)
|
||||
os.exit(1)
|
||||
}
|
||||
|
||||
fmt.print(result)
|
||||
}
|
||||
Reference in New Issue
Block a user