Templates mit HTMX

This commit is contained in:
2026-09-09 21:31:08 +02:00
parent 870a3cf708
commit d1e210d03e
8 changed files with 63 additions and 45 deletions
@@ -0,0 +1,48 @@
package handlers
import (
"html/template"
"net/http"
"github.com/gin-gonic/gin"
)
func Home(ctx *gin.Context) {
tmpl, err := template.ParseFiles(
"../templates/pages/index.html",
"../templates/layouts/navbar.html",
"../templates/layouts/properties.html",
"../templates/layouts/footer.html")
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
})
return
}
err = tmpl.Execute(ctx.Writer, nil)
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
})
}
}
func PropertiesHandler(ctx *gin.Context) {
ptmpl, err := template.ParseFiles(
"../templates/layouts/properties.html")
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
})
return
}
err = ptmpl.Execute(ctx.Writer, nil)
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
})
}
}