Fixed 'Error parsing template: template: privacy.html:27: function "translate"'
Some checks failed
Run Integration Tests / test (push) Failing after 39s
Some checks failed
Run Integration Tests / test (push) Failing after 39s
This commit is contained in:
parent
8e0682cb43
commit
66414952e8
3 changed files with 11 additions and 17 deletions
|
@ -173,3 +173,12 @@ func FormatLinkHTML(rawURL string) LinkParts {
|
||||||
|
|
||||||
return lp
|
return lp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Converts any struct to a map[string]interface{} using JSON round-trip.
|
||||||
|
// Useful for rendering templates with generic map input.
|
||||||
|
func toMap(data interface{}) map[string]interface{} {
|
||||||
|
jsonBytes, _ := json.Marshal(data)
|
||||||
|
var result map[string]interface{}
|
||||||
|
_ = json.Unmarshal(jsonBytes, &result)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
17
main.go
17
main.go
|
@ -282,20 +282,5 @@ func handlePrivacyPage(w http.ResponseWriter, r *http.Request) {
|
||||||
LanguageOptions: languageOptions,
|
LanguageOptions: languageOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the template
|
renderTemplate(w, "privacy.html", toMap(data))
|
||||||
tmpl, err := template.New("privacy.html").ParseFiles("templates/privacy.html")
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error parsing template: %v", err)
|
|
||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the response content type
|
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
||||||
|
|
||||||
// Execute the template
|
|
||||||
if err := tmpl.Execute(w, data); err != nil {
|
|
||||||
log.Printf("Error executing template: %v", err)
|
|
||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
alt="QGato"
|
alt="QGato"
|
||||||
>
|
>
|
||||||
<h2>{{ translate "site_name" }}</h2>
|
<h2>{{ translate "site_name" }}</h2>
|
||||||
<p>{{ translate "site_description" }</p>
|
<p>{{ translate "site_description" }}</p>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<button onclick="window.location.href='https://weforge.xyz/Spitfire/Search'">Source Code</button>
|
<button onclick="window.location.href='https://weforge.xyz/Spitfire/Search'">Source Code</button>
|
||||||
<button onclick="window.location.href='/privacy'">Privacy policy</button>
|
<button onclick="window.location.href='/privacy'">Privacy policy</button>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue