1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Simple GSX component example
// Tests basic syntax highlighting
package example
import (
"fmt"
tui "github.com/grindlemire/go-tui"
)
templ Header(title string) {
<div class="border-single p-1">
<span class="font-bold">{title}</span>
</div>
}
templ Footer() {
<div class="p-1">
<span>Footer content</span>
</div>
}
templ SimpleCard(title string, content string) {
<div class="border-rounded">
<span class="font-bold">{title}</span>
<span>{content}</span>
</div>
}
// Ref attribute example
templ Layout(title string) {
main := tui.NewRef()
titleRef := tui.NewRef()
<div ref={main} class="flex-col gap-1">
<span ref={titleRef} class="font-bold">{title}</span>
<span>Body content</span>
</div>
}
// State variable example
templ Counter() {
count := tui.NewState(0)
<div class="flex-col gap-1 p-1 border-single">
<span>{fmt.Sprintf("Count: %d", count.Get())}</span>
</div>
}
|