From 47c4143081176b08af8793524287710a9a0e7290 Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Sat, 15 Oct 2022 20:46:26 -0600 Subject: unesacpe html and highlight --- main.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 44f5bdc..6302b6a 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,19 @@ func main() { t.Execute(w, nil) }) - searchResTemplate := template.Must(template.ParseFiles("results.gtpl")) + funcMap := template.FuncMap{ + "unescapeHTML": func(s string) template.HTML { + return template.HTML(s) + }, + } + + //searchResTemplate := template.Must(template.ParseFiles("results.gtpl")) + searchResTemplate := template.Must(template.New("results.gtpl").Funcs(funcMap).ParseFiles("results.gtpl")) + + if err != nil { + fmt.Println("Error parsing template") + os.Exit(1) + } http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() @@ -84,6 +96,17 @@ func main() { res, err := index.Search(query.Query, &meilisearch.SearchRequest{ Limit: query.MaxResults, Offset: query.Offset, + AttributesToRetrieve: []string{ + "title", + "applicant", + "submission_date", + "predicates", + "id", + }, + AttributesToCrop: []string{"full_text"}, + AttributesToHighlight: []string{"full_text"}, + HighlightPreTag: "", + HighlightPostTag: "", }) if err != nil { -- cgit v1.2.3