Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

run templates through the markdown engine first before going through plush #307

Merged
merged 1 commit into from
Mar 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions render/template.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package render

import (
"html"
"html/template"
"io"
"path/filepath"
Expand Down Expand Up @@ -41,8 +42,7 @@ func (s templateRenderer) partial(name string, dd Data) (template.HTML, error) {
}

func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
var body string
source, err := s.TemplatesBox.MustString(name)
source, err := s.TemplatesBox.MustBytes(name)
if err != nil {
return "", err
}
Expand All @@ -55,15 +55,16 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
helpers[k] = v
}

body, err = s.TemplateEngine(source, data, helpers)
if strings.ToLower(filepath.Ext(name)) == ".md" {
source = github_flavored_markdown.Markdown(source)
source = []byte(html.UnescapeString(string(source)))
}

body, err := s.TemplateEngine(string(source), data, helpers)
if err != nil {
return "", err
}

if strings.ToLower(filepath.Ext(name)) == ".md" {
b := github_flavored_markdown.Markdown([]byte(body))
body = string(b)
}
return template.HTML(body), nil
}

Expand Down