Skip to content
Snippets Groups Projects
Commit 2a742483 authored by ale's avatar ale
Browse files

render the book description as HTML

parent 885b31c4
No related branches found
No related tags found
No related merge requests found
...@@ -52,9 +52,10 @@ func testEbook() *Book { ...@@ -52,9 +52,10 @@ func testEbook() *Book {
return &Book{ return &Book{
Id: NewID(), Id: NewID(),
Metadata: &Metadata{ Metadata: &Metadata{
Title: "20,000 Leagues under the sea", Title: "20,000 Leagues under the sea",
Creator: []string{"Jules Verne"}, Creator: []string{"Jules Verne"},
ISBN: []string{"1234"}, ISBN: []string{"1234"},
Description: "A pretty cool book.",
}, },
} }
} }
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
</p> </p>
{{end}} {{end}}
{{if .Book.Metadata.Description}} {{if .Description}}
<p>{{.Book.Metadata.Description}}</p> <p>{{.Description}}</p>
{{end}} {{end}}
{{range $i, $f := .Files}} {{range $i, $f := .Files}}
......
...@@ -149,11 +149,18 @@ func (s *uiServer) handleShowBook(book *Book, w http.ResponseWriter, req *http.R ...@@ -149,11 +149,18 @@ func (s *uiServer) handleShowBook(book *Book, w http.ResponseWriter, req *http.R
return return
} }
// The book's Description, if present, should be rendered
// directly as HTML. So we deal with it separately.
ctx := struct { ctx := struct {
Query string Query string
Book *Book Book *Book
Files []*File Files []*File
}{Book: book, Files: files} Description template.HTML
}{
Book: book,
Files: files,
Description: template.HTML(book.Metadata.Description),
}
render("book.html", w, &ctx) render("book.html", w, &ctx)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment