removed unused .gitkeep files and cleaned up render function
This commit is contained in:
parent
1543bd1e53
commit
591323a2f8
|
|
@ -7,7 +7,6 @@ GoFiber Secure MVC Starter is a production-grade, server-first web application f
|
||||||
It combines:
|
It combines:
|
||||||
|
|
||||||
- Clean MVC layering
|
- Clean MVC layering
|
||||||
- HTMX progressive enhancement
|
|
||||||
- Web Components for reusable UI
|
- Web Components for reusable UI
|
||||||
- Secure authentication flows
|
- Secure authentication flows
|
||||||
- Role-based access control
|
- Role-based access control
|
||||||
|
|
|
||||||
|
|
@ -47,45 +47,6 @@ func renderPublic(c *fiber.Ctx, page string, data map[string]any) error {
|
||||||
return c.Send(out.Bytes())
|
return c.Send(out.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderPrivate(c *fiber.Ctx, _ string, data map[string]any) error {
|
|
||||||
viewData := map[string]any{}
|
|
||||||
for k, v := range localsTemplateData(c) {
|
|
||||||
viewData[k] = v
|
|
||||||
}
|
|
||||||
for k, v := range data {
|
|
||||||
viewData[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := viewData["Title"]; !ok {
|
|
||||||
viewData["Title"] = "Trustcontact"
|
|
||||||
}
|
|
||||||
if _, ok := viewData["NavSection"]; !ok {
|
|
||||||
viewData["NavSection"] = "private"
|
|
||||||
}
|
|
||||||
|
|
||||||
files := []string{
|
|
||||||
"web/templates/layout.html",
|
|
||||||
"web/templates/public/_navbar.html",
|
|
||||||
"web/templates/partials/language_dropdown.html",
|
|
||||||
"web/templates/partials/user_dropdown.html",
|
|
||||||
"web/templates/public/_flash.html",
|
|
||||||
"web/templates/private.html",
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(files...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var out bytes.Buffer
|
|
||||||
if err := tmpl.ExecuteTemplate(&out, "layout.html", viewData); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Type("html", "utf-8")
|
|
||||||
return c.Send(out.Bytes())
|
|
||||||
}
|
|
||||||
|
|
||||||
func localsTemplateData(c *fiber.Ctx) map[string]any {
|
func localsTemplateData(c *fiber.Ctx) map[string]any {
|
||||||
data, ok := c.Locals("template_data").(map[string]any)
|
data, ok := c.Locals("template_data").(map[string]any)
|
||||||
if !ok || data == nil {
|
if !ok || data == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue