From 0adac5c6f7d3c03298a73a223d627813cc7ae0d6 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 25 Feb 2024 15:42:08 +0100 Subject: [PATCH] Minor code simplification in internal/ui/view/view.go No need to create the map item by item when we can create it in one go. --- internal/ui/view/view.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/ui/view/view.go b/internal/ui/view/view.go index 077340b5..742bb3a9 100644 --- a/internal/ui/view/view.go +++ b/internal/ui/view/view.go @@ -33,18 +33,18 @@ func (v *View) Render(template string) []byte { // New returns a new view with default parameters. func New(tpl *template.Engine, r *http.Request, sess *session.Session) *View { - b := &View{tpl, r, make(map[string]interface{})} theme := request.UserTheme(r) - b.params["menu"] = "" - b.params["csrf"] = request.CSRF(r) - b.params["flashMessage"] = sess.FlashMessage(request.FlashMessage(r)) - b.params["flashErrorMessage"] = sess.FlashErrorMessage(request.FlashErrorMessage(r)) - b.params["theme"] = theme - b.params["language"] = request.UserLanguage(r) - b.params["theme_checksum"] = static.StylesheetBundleChecksums[theme] - b.params["app_js_checksum"] = static.JavascriptBundleChecksums["app"] - b.params["sw_js_checksum"] = static.JavascriptBundleChecksums["service-worker"] - b.params["webauthn_js_checksum"] = static.JavascriptBundleChecksums["webauthn"] - b.params["webAuthnEnabled"] = config.Opts.WebAuthn() - return b + return &View{tpl, r, map[string]interface{}{ + "menu": "", + "csrf": request.CSRF(r), + "flashMessage": sess.FlashMessage(request.FlashMessage(r)), + "flashErrorMessage": sess.FlashErrorMessage(request.FlashErrorMessage(r)), + "theme": theme, + "language": request.UserLanguage(r), + "theme_checksum": static.StylesheetBundleChecksums[theme], + "app_js_checksum": static.JavascriptBundleChecksums["app"], + "sw_js_checksum": static.JavascriptBundleChecksums["service-worker"], + "webauthn_js_checksum": static.JavascriptBundleChecksums["webauthn"], + "webAuthnEnabled": config.Opts.WebAuthn(), + }} }