Initial commit

This commit is contained in:
Ivan 2025-07-01 13:21:08 +05:00
commit 7139f74b18
Signed by: landlord
GPG key ID: 416A03BC4ADA4CD7
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()
}

View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" width="24px" viewBox="0 -960 960 960" fill="#e3e3e3">
<path d="m354-287 126-76 126 77-33-144 111-96-146-13-58-136-58 135-146 13 111 97-33 143ZM233-120l65-281L80-590l288-25 112-265 112 265 288 25-218 189 65 281-247-149-247 149Zm247-350Z"/>
</svg>

After

Width:  |  Height:  |  Size: 302 B

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
{{ block "main" . }}{{ end }}
</body>
</html>

View file

@ -0,0 +1,6 @@
{{ template "layouts/base.html" . }}
{{ define "main" }}
{{ template "icons/material/favicon.svg" . }}
<h1>Index</h1>
{{ end }}