From b336e95e1244007426a4c3fb66d7691424c9d3ed Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 20 Jan 2020 15:20:45 -0500 Subject: [PATCH] Render HTML entities in Drafts list Previously, we'd show the raw HTML entities in the summaries of Draft posts, instead of rendering them. This fixes that. --- posts.go | 4 ++++ templates/user/articles.tmpl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/posts.go b/posts.go index d2fbcca..608f2fc 100644 --- a/posts.go +++ b/posts.go @@ -229,6 +229,10 @@ func (p Post) Summary() string { return shortPostDescription(p.Content) } +func (p Post) SummaryHTML() template.HTML { + return template.HTML(p.Summary()) +} + // Excerpt shows any text that comes before a (more) tag. // TODO: use HTMLExcerpt in templates instead of this method func (p *Post) Excerpt() template.HTML { diff --git a/templates/user/articles.tmpl b/templates/user/articles.tmpl index 3edb89c..5dbe47b 100644 --- a/templates/user/articles.tmpl +++ b/templates/user/articles.tmpl @@ -34,7 +34,7 @@ {{end}} {{ end }} - {{if .Summary}}

{{.Summary}}

{{end}} + {{if .Summary}}

{{.SummaryHTML}}

{{end}} {{end}} {{ else }}

You haven't saved any drafts yet.

They'll show up here once you do. {{if not .SingleUser}}Find your blog posts from the Blogs page.{{end}}