Initial commit

This commit is contained in:
Ivan 2025-07-01 13:19:40 +05:00
commit be06319cc3
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
8 changed files with 942 additions and 0 deletions

43
examples/main.go Normal file
View file

@ -0,0 +1,43 @@
package main
import (
"bufio"
"log/slog"
"os"
"code.app-house.ru/go/tl"
)
func main() {
templates, err := tl.LoadWithOptions(
// Main templates.
tl.Collection{
RootDir: "templates/pages",
},
tl.Options{
SharedCollections: []tl.Collection{
tl.Collection{
RootDir: "templates/layouts",
Prefix: "layouts", // template name prefix, may be omitted.
},
tl.Collection{
RootDir: "templates/icons",
Prefix: "icons",
},
// you can add other collections (e.g. snippets, components...)
},
},
)
if err != nil {
slog.Error("can't load templates", "err", err)
os.Exit(-1)
}
w := bufio.NewWriter(os.Stdout)
err = templates["index.html"].Execute(w, nil)
if err != nil {
slog.Error("can't execute index.html", "err", err)
os.Exit(-1)
}
w.Flush()
}