don't escape notes
This commit is contained in:
parent
48a11ab6d7
commit
29eea1d837
|
@ -3,7 +3,7 @@
|
||||||
<div class="h-entry">
|
<div class="h-entry">
|
||||||
<hgroup>
|
<hgroup>
|
||||||
{{ if eq .Meta.Type "note"}}
|
{{ if eq .Meta.Type "note"}}
|
||||||
<p>{{.RenderedContent}}</p>
|
<p>{{.RenderedContent | noescape}}</p>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<h3><a class="u-url" href="{{.UrlPath}}">
|
<h3><a class="u-url" href="{{.UrlPath}}">
|
||||||
{{ if .Title }}{{.Title}}{{ else }}{{.Id}}{{ end }}
|
{{ if .Title }}{{.Title}}{{ else }}{{.Id}}{{ end }}
|
||||||
|
|
|
@ -45,6 +45,10 @@ type ErrorMessage struct {
|
||||||
Message string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func noescape(str string) template.HTML {
|
||||||
|
return template.HTML(str)
|
||||||
|
}
|
||||||
|
|
||||||
func renderEmbedTemplate(templateFile string, data interface{}) (string, error) {
|
func renderEmbedTemplate(templateFile string, data interface{}) (string, error) {
|
||||||
templateStr, err := embed_files.ReadFile(templateFile)
|
templateStr, err := embed_files.ReadFile(templateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,7 +58,9 @@ func renderEmbedTemplate(templateFile string, data interface{}) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderTemplateStr(templateStr []byte, data interface{}) (string, error) {
|
func renderTemplateStr(templateStr []byte, data interface{}) (string, error) {
|
||||||
t, err := template.New("_").Parse(string(templateStr))
|
t, err := template.New("_").Funcs(template.FuncMap{
|
||||||
|
"noescape": noescape,
|
||||||
|
}).Parse(string(templateStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,7 @@ func TestRenderNoteAsFullContent(t *testing.T) {
|
||||||
Include: []string{"note"},
|
Include: []string{"note"},
|
||||||
})
|
})
|
||||||
assertions.AssertContains(t, result, "This is a note")
|
assertions.AssertContains(t, result, "This is a note")
|
||||||
|
assertions.AssertNotContains(t, result, "<p>This is a note")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIndexPageContainsHFeedContainer(t *testing.T) {
|
func TestIndexPageContainsHFeedContainer(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue