]> Nishi Git Mirror - aya.git/commitdiff
moved html rendering into a separate function
authorSerge A. Zaitsev <zaitsev.serge@gmail.com>
Sat, 29 Aug 2015 13:07:18 +0000 (15:07 +0200)
committerSerge A. Zaitsev <zaitsev.serge@gmail.com>
Sat, 29 Aug 2015 13:07:18 +0000 (15:07 +0200)
zs.go

diff --git a/zs.go b/zs.go
index 4f6b698394ed520c4d1365891db391d8a8a7fec4..38aec242010df6780a38c168caf79286b716996a 100644 (file)
--- a/zs.go
+++ b/zs.go
@@ -145,15 +145,23 @@ func buildMarkdown(path string) error {
                return err
        }
        v["content"] = string(blackfriday.MarkdownBasic([]byte(content)))
-       b, err = ioutil.ReadFile(filepath.Join(ZSDIR, v["layout"]))
+       return buildPlain(filepath.Join(ZSDIR, v["layout"]), v)
+}
+
+func buildPlain(path string, vars map[string]string) error {
+       b, err := ioutil.ReadFile(path)
        if err != nil {
                return err
        }
-       content, err = render(string(b), v, eval)
+       content, err := render(string(b), vars, eval)
        if err != nil {
                return err
        }
-       err = ioutil.WriteFile(v["output"], []byte(content), 0666)
+       output := filepath.Join(PUBDIR, path)
+       if s, ok := vars["output"]; ok {
+               output = s
+       }
+       err = ioutil.WriteFile(output, []byte(content), 0666)
        if err != nil {
                return err
        }