diff --git a/cmd/main.go b/cmd/main.go index 3aedb03..0c9ed95 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,6 +1,7 @@ package main import ( + "html/template" "log" "github.com/gin-gonic/gin" @@ -21,13 +22,20 @@ func main() { // Initialize Gin router router := gin.Default() + // Register the safeHTML function + router.SetFuncMap(template.FuncMap{ + "safeHTML": func(s string) template.HTML { + return template.HTML(s) + }, + }) + // Load HTML templates router.LoadHTMLGlob("templates/*") // Serve static files (CSS) router.Static("/static", "./static") - // Initialize API handlers (MOVE THIS UP!) + // Initialize API handlers apiHandler := api.NewAPIHandler(database) // Define API routes @@ -41,7 +49,7 @@ func main() { apiGroup.DELETE("/:id", apiHandler.DeleteNombre) } - // HTML Routes (MOVE THIS DOWN!) + // HTML Routes apiGroup.GET("/html", apiHandler.GetNombresHTML) apiGroup.GET("/html/:id", apiHandler.GetNombreByIDHTML) diff --git a/templates/nombre.html b/templates/nombre.html index 5b991ad..d25b25f 100644 --- a/templates/nombre.html +++ b/templates/nombre.html @@ -2,20 +2,51 @@ - Nombre + Nombre Details

Nombre Details

-

NombreID: {{ .NombreID }}

-

FamiliaID: {{ .FamiliaID }}

-

Nombre: {{ .Nombre }}

-

Fecha: {{ .Fecha }}

-

ProveedorID: {{ .ProveedorID }}

-

Precio: {{ .Precio }}

-

Inactivo: {{ .Inactivo }}

- Back to List + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldValue
NombreID{{ .NombreID }}
FamiliaID{{ .FamiliaID }}
Nombre{{ .Nombre | safeHTML }}
Fecha{{ .Fecha }}
ProveedorID{{ .ProveedorID }}
Precio{{ .Precio }}
Inactivo{{ .Inactivo }}
+ Back to List \ No newline at end of file diff --git a/templates/nombres.html b/templates/nombres.html index b5debde..65fa3be 100644 --- a/templates/nombres.html +++ b/templates/nombres.html @@ -1,13 +1,39 @@ - - {{ range . }} - - {{ .NombreID }} - {{ .FamiliaID }} - {{ .Nombre }} - {{ .Fecha }} - {{ .ProveedorID }} - {{ .Precio }} - {{ .Inactivo }} - - {{ end }} - \ No newline at end of file + + + + + Nombres + + + + +

Nombres

+ + + + + + + + + + + + + + {{ range . }} + + + + + + + + + + {{ end }} + +
NombreIDFamiliaIDNombreFechaProveedorIDPrecioInactivo
{{ .NombreID }}{{ .FamiliaID }}{{ .Nombre | safeHTML }}{{ .Fecha }}{{ .ProveedorID }}{{ .Precio }}{{ .Inactivo }}
+ + + \ No newline at end of file