summaryrefslogtreecommitdiff
path: root/internal/handlers
diff options
context:
space:
mode:
authorGrailFinder <wohilas@gmail.com>2024-03-23 16:39:52 +0300
committerGrailFinder <wohilas@gmail.com>2024-03-23 16:39:52 +0300
commit4ea04ef5b382b147d789240ef78dc24bd142df95 (patch)
treef2d61824aefae9a87312d4a73874701e10d1b9c4 /internal/handlers
parent87d71e65ed131b3e15510af968dd5ba0d30d851d (diff)
Enha: demonstraton of layouts
Diffstat (limited to 'internal/handlers')
-rw-r--r--internal/handlers/main.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/internal/handlers/main.go b/internal/handlers/main.go
index 1934250..4abc8e1 100644
--- a/internal/handlers/main.go
+++ b/internal/handlers/main.go
@@ -43,9 +43,14 @@ func (h *Handlers) Ping(w http.ResponseWriter, r *http.Request) {
func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) {
h.log.Info("got mainpage request")
- tmpl := template.Must(template.
- ParseFiles("components/index.html"))
- tmpl.Execute(w, us)
+ // tmpl := template.Must(template.ParseFiles("components/index.html"))
+ tmpl, err := template.ParseGlob("components/*.html")
+ if err != nil {
+ panic(err)
+ }
+ // tmpl.Execute(w, us)
+ us.ID = "test"
+ tmpl.ExecuteTemplate(w, "main", us)
}
func (h *Handlers) HandleForm(w http.ResponseWriter, r *http.Request) {
@@ -53,7 +58,7 @@ func (h *Handlers) HandleForm(w http.ResponseWriter, r *http.Request) {
h.log.Info("got postform request", "payload", r.PostForm)
magnitude := uint8(1)
mS := r.PostFormValue("magnitude")
- if mS != "1" || mS != "" {
+ if mS != "1" || mS != "" || mS != " " {
u64, err := strconv.ParseUint(mS, 10, 64)
magnitude = uint8(u64)
if err != nil {
@@ -83,7 +88,8 @@ func (h *Handlers) HandleForm(w http.ResponseWriter, r *http.Request) {
Repeatable: repeat,
}
us.Actions = append(us.Actions, act)
- tmpl := template.Must(template.
- ParseFiles("components/index.html"))
- tmpl.Execute(w, us)
+ tmpl := template.Must(template.ParseGlob("components/*.html"))
+ // tmpl := template.Must(template.ParseFiles("components/index.html"))
+ // tmpl.Execute(w, us)
+ tmpl.ExecuteTemplate(w, "main", us)
}