-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_templ.go
81 lines (73 loc) · 3.2 KB
/
app_templ.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.747
package main
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
func App() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><script defer src=\"https://unpkg.com/[email protected]\"></script><link rel=\"stylesheet\" href=\"/public/styles.css\"></head><body><button type=\"button\">Some other button</button> <button id=\"submitButton\" hx-post=\"/button\" hx-target=\"body\" hx-swap=\"outerHTML\" type=\"submit\">Click me</button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = SetupListeners().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
func SetupListeners() templ.ComponentScript {
return templ.ComponentScript{
Name: `__templ_SetupListeners_b828`,
Function: `function __templ_SetupListeners_b828(){const submitButton = document.querySelector("#submitButton")
submitButton.addEventListener("click", function(event) {
submitButton.classList.add("closing")
});
submitButton.addEventListener("animationend", function(event) {
submitButton.remove();
});
document.body.addEventListener("htmx:beforeRequest", function(event) {
console.log("htmx:beforeRequest", event);
const button = document.querySelector("button");
button.disabled = true;
button.textContent = "Loading...";
});
document.body.addEventListener("htmx:afterRequest", function(event) {
console.log("htmx:afterRequest", event);
const button = document.querySelector("button");
button.disabled = false;
button.textContent = "Click me";
});
document.body.addEventListener("htmx:responseError", function(event) {
console.log("htmx:responseError", event);
const buttons = document.querySelector("button")
const button = document.querySelector("button")
button.disabled = false
button.textContent = "Click me"
});
}`,
Call: templ.SafeScript(`__templ_SetupListeners_b828`),
CallInline: templ.SafeScriptInline(`__templ_SetupListeners_b828`),
}
}