From f891b0288be4fe26206aca686a38557b58142964 Mon Sep 17 00:00:00 2001 From: Robert Janetzko Date: Sat, 7 May 2022 20:24:58 +0000 Subject: [PATCH] debug json config --- backend/main.go | 1 + backend/server/config.go | 1 + backend/server/templates.go | 10 +++++++++- backend/templates/events.html | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/main.go b/backend/main.go index 0283d66..19cdc7e 100644 --- a/backend/main.go +++ b/backend/main.go @@ -37,6 +37,7 @@ func main() { log.Fatal(err) } + server.DebugJSON = config.DebugJSON templates.DebugTemplates = config.DebugTemplates var world *model.DfWorld diff --git a/backend/server/config.go b/backend/server/config.go index bef87ee..dc313d6 100644 --- a/backend/server/config.go +++ b/backend/server/config.go @@ -13,6 +13,7 @@ type Config struct { LastPath string LastFile string DebugTemplates bool `json:"DebugTemplates,omitempty"` + DebugJSON bool `json:"DebugJSON,omitempty"` } func LoadConfig(path string) (*Config, error) { diff --git a/backend/server/templates.go b/backend/server/templates.go index 283133e..b784b12 100644 --- a/backend/server/templates.go +++ b/backend/server/templates.go @@ -12,9 +12,17 @@ import ( "github.com/robertjanetzko/LegendsBrowser2/backend/util" ) +var DebugJSON = false + func (srv *DfServer) LoadTemplates() { functions := template.FuncMap{ - "json": util.Json, + "json": func(obj any) template.HTML { + if !DebugJSON { + return "" + } else { + return util.Json(obj) + } + }, "check": func(condition bool, v any) any { if condition { return v diff --git a/backend/templates/events.html b/backend/templates/events.html index 8fbcff9..ba12e1f 100644 --- a/backend/templates/events.html +++ b/backend/templates/events.html @@ -1,7 +1,7 @@