Templates mit HTMX
This commit is contained in:
@@ -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(),
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user