diff --git a/pkg/contacts.go b/pkg/contacts.go index 9486944..b298a80 100644 --- a/pkg/contacts.go +++ b/pkg/contacts.go @@ -24,7 +24,7 @@ func IndexContacts(w http.ResponseWriter, r *http.Request, _ httprouter.Params) page := &ContactsIndexPage{ Contacts: mustGetContactEntries(r.Context(), conn, company), } - mustRenderAppTemplate(w, r, "contacts/index.gohtml", page) + mustRenderMainTemplate(w, r, "contacts/index.gohtml", page) } func GetContactForm(w http.ResponseWriter, r *http.Request, params httprouter.Params) { diff --git a/pkg/invoices.go b/pkg/invoices.go index 6878312..5beac9e 100644 --- a/pkg/invoices.go +++ b/pkg/invoices.go @@ -46,7 +46,7 @@ func IndexInvoices(w http.ResponseWriter, r *http.Request, _ httprouter.Params) Invoices: mustCollectInvoiceEntries(r.Context(), conn, mustGetCompany(r), locale, tag), InvoiceStatuses: mustCollectInvoiceStatuses(r.Context(), conn, locale), } - mustRenderAppTemplate(w, r, "invoices/index.gohtml", page) + mustRenderMainTemplate(w, r, "invoices/index.gohtml", page) } func mustCollectInvoiceEntries(ctx context.Context, conn *Conn, company *Company, locale *Locale, tag string) []*InvoiceEntry { diff --git a/pkg/products.go b/pkg/products.go index 1c6d890..b49ba21 100644 --- a/pkg/products.go +++ b/pkg/products.go @@ -26,7 +26,7 @@ func IndexProducts(w http.ResponseWriter, r *http.Request, _ httprouter.Params) page := &productsIndexPage{ Products: mustGetProductEntries(r.Context(), conn, company), } - mustRenderAppTemplate(w, r, "products/index.gohtml", page) + mustRenderMainTemplate(w, r, "products/index.gohtml", page) } func GetProductForm(w http.ResponseWriter, r *http.Request, params httprouter.Params) { diff --git a/pkg/router.go b/pkg/router.go index 0f94ce8..d82bd56 100644 --- a/pkg/router.go +++ b/pkg/router.go @@ -32,7 +32,7 @@ func NewRouter(db *Db) http.Handler { companyRouter.GET("/invoices/:slug/edit", ServeEditInvoice) companyRouter.POST("/invoices/:slug/edit", HandleEditInvoiceAction) companyRouter.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - mustRenderAppTemplate(w, r, "dashboard.gohtml", nil) + mustRenderMainTemplate(w, r, "dashboard.gohtml", nil) }) router := httprouter.New() diff --git a/pkg/template.go b/pkg/template.go index 42b21f7..f234dd2 100644 --- a/pkg/template.go +++ b/pkg/template.go @@ -100,11 +100,19 @@ func mustRenderAppTemplate(w io.Writer, r *http.Request, filename string, data i } func mustRenderModalTemplate(w io.Writer, r *http.Request, filename string, data interface{}) { - layout := "app.gohtml" if IsHTMxRequest(r) { - layout = "modal.gohtml" + mustRenderTemplate(w, r, "modal.gohtml", filename, data) + } else { + mustRenderAppTemplate(w, r, filename, data) + } +} + +func mustRenderMainTemplate(w io.Writer, r *http.Request, filename string, data interface{}) { + if IsHTMxRequest(r) { + mustRenderTemplate(w, r, "main.gohtml", filename, data) + } else { + mustRenderAppTemplate(w, r, filename, data) } - mustRenderTemplate(w, r, layout, filename, data) } func mustRenderWebTemplate(w io.Writer, r *http.Request, filename string, data interface{}) { diff --git a/web/template/app.gohtml b/web/template/app.gohtml index 54686ae..794818b 100644 --- a/web/template/app.gohtml +++ b/web/template/app.gohtml @@ -40,7 +40,7 @@ -