aboutsummaryrefslogtreecommitdiff
path: root/page/page.go
diff options
context:
space:
mode:
Diffstat (limited to 'page/page.go')
-rw-r--r--page/page.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/page/page.go b/page/page.go
index 214021e..03d1f1e 100644
--- a/page/page.go
+++ b/page/page.go
@@ -59,7 +59,7 @@ type Page struct {
Vars map[string]interface{}
// Keys of vars to be included when RenderJson is called, all vars are
// omitted if empty.
- JsonVars []string
+ JSONVars []string
markdown []byte
}
@@ -69,7 +69,7 @@ type Page struct {
var Global interface{}
// Funcs accessible to the templates.
-var Funcs template.FuncMap = template.FuncMap{
+var Funcs = template.FuncMap{
"join": strings.Join,
"split": strings.Split,
"toLower": strings.ToLower,
@@ -191,7 +191,12 @@ func (p *Page) Render(wr io.Writer) error {
t = t.Funcs(Funcs)
- return t.Execute(wr, p)
+ err = t.Execute(wr, p)
+ if err != nil {
+ return fmt.Errorf("while executing template: %w", err)
+ }
+
+ return nil
}
// Read in the special markdown file format for the website off of the disk.
@@ -253,6 +258,7 @@ func (p *Page) Read() error {
// this is called in the base template.
func (p *Page) RenderBody() (string, error) {
s, err := p.GetMarkdown()
+
return string(blackfriday.Run([]byte(s))), err
}
@@ -278,3 +284,15 @@ func (p *Page) GetMarkdown() (string, error) {
func (p Page) String() string {
return fmt.Sprintf("Page: %s", p.path)
}
+
+// setRenderingMarkdownOnly simply sets the special vars field,
+// "RenderingMarkdownOnly" to be true.
+func (p *Page) setRenderingMarkdownOnly() {
+ if p.Vars != nil {
+ p.Vars["RenderingMarkdownOnly"] = true
+ } else {
+ p.Vars = map[string]interface{}{
+ "RenderingMarkdownOnly": true,
+ }
+ }
+}