debug json config

This commit is contained in:
Robert Janetzko 2022-05-07 20:24:58 +00:00
parent 6380871358
commit f891b0288b
4 changed files with 13 additions and 3 deletions

View File

@ -37,6 +37,7 @@ func main() {
log.Fatal(err)
}
server.DebugJSON = config.DebugJSON
templates.DebugTemplates = config.DebugTemplates
var world *model.DfWorld

View File

@ -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) {

View File

@ -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

View File

@ -1,7 +1,7 @@
<ul class="mb-0">
{{- range $event := .Events }}
<li>
[{{ $event.Id }}] In {{ time $event.Year $event.Seconds72 }},
<li data-event-id="{{ $event.Id }}">
In {{ time $event.Year $event.Seconds72 }},
{{ html ($event.Details.Html ($.Context.WithEvent $event)) }}
{{ if ne .Collection -1 }} <a class="collection" href="/collection/{{.Collection}}"><i
class="fa-solid fa-magnifying-glass fa-xs"></i></a>{{end}}