1This is a base page template. All the other template pages implement this interface.
2
3{% import "context" %}
4{% import "strconv" %}
5{% import "time" %}
6
7{% code
8 var Slug = ""
9%}
10
11{% interface
12Page {
13 Title(ctx context.Context)
14 Content(ctx context.Context)
15 Script(ctx context.Context)
16 Navbar(ctx context.Context)
17}
18%}
19
20
21{% code func FromUInttoString(u *uint) string {
22 if u != nil {
23 return strconv.FormatUint(uint64(*u), 10)
24 }
25 return ""
26 }
27%}
28
29
30
31{% code func TimeFormat(t time.Time) string {
32 return t.Format("02.01.2006")
33 }
34%}
35
36{% code func Ignore[T any](v T, _ error) T {
37 return v
38 }
39%}
40
41{% code func IsLoggedIn(ctx context.Context) bool {
42 t, ok := ctx.Value("logged").(bool)
43 return ok && t
44 }
45%}
46
47Page prints a page implementing Page interface.
48{% func PageTemplate(p Page, ctx context.Context) %}
49<!DOCTYPE html>
50<html lang="en">
51 <head>
52 <meta charset="utf-8">
53 <link rel="icon" href="data:,">
54 <title>{%= p.Title(ctx) %}</title>
55 <link rel="stylesheet" href="/static/main{%s Slug %}.css">
56 <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
57 <meta name="viewport" content="width=device-width, initial-scale=1" />
58 </head>
59 <body>
60 {%= p.Navbar(ctx) %}
61 <div class="container">
62 {%= p.Content(ctx) %}
63 </div>
64 </body>
65 {%= p.Script(ctx) %}
66</html>
67{% endfunc %}