mirror of
https://github.com/Luzifer/ots.git
synced 2025-04-19 06:55:51 -04:00
Remove map allocation in index template
We have only a single variable left, better to remove the map/loop for now.
This commit is contained in:
parent
236c6a8dcb
commit
fdd9eb6092
@ -41,9 +41,7 @@
|
||||
document.addEventListener('DOMContentLoaded', () => window.refreshTheme())
|
||||
|
||||
// Template variable from Golang process
|
||||
{{- range $key, $value := .Vars }}
|
||||
const {{ $key }} = "{{ $value }}"
|
||||
{{- end }}
|
||||
const version = "{{ .Version }}"
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
8
main.go
8
main.go
@ -120,12 +120,10 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Security-Policy", cspHeader)
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
|
||||
if err = tpl.Execute(w, struct {
|
||||
Vars map[string]string
|
||||
if err := indexTpl.Execute(w, struct {
|
||||
Version string
|
||||
}{
|
||||
Vars: map[string]string{
|
||||
"version": version,
|
||||
},
|
||||
Version: version,
|
||||
}); err != nil {
|
||||
http.Error(w, errors.Wrap(err, "executing template").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user