From: Serge A. Zaitsev Date: Sat, 29 Aug 2015 13:07:18 +0000 (+0200) Subject: moved html rendering into a separate function X-Git-Tag: 0.0.1~35 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=862f4d7162f6aaa4c25fed920957341497e6aa57;p=aya.git moved html rendering into a separate function --- diff --git a/zs.go b/zs.go index 4f6b698..38aec24 100644 --- 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 }