]> Nishi Git Mirror - aya.git/commitdiff
fixed variable override order
authorSerge A. Zaitsev <zaitsev.serge@gmail.com>
Wed, 2 Sep 2015 17:43:31 +0000 (19:43 +0200)
committerSerge A. Zaitsev <zaitsev.serge@gmail.com>
Wed, 2 Sep 2015 17:43:31 +0000 (19:43 +0200)
zs.go

diff --git a/zs.go b/zs.go
index de98d56a3677a7fe6bc77c6326c8bc4f8a1d03ca..6b497a725cffd541caf8f5bd7b80a74188a2f420 100644 (file)
--- a/zs.go
+++ b/zs.go
@@ -99,21 +99,23 @@ func getVars(path string, globals Vars) (Vars, string, error) {
        }
        s := string(b)
 
-       // Copy globals first
+       // Pick some default values for content-dependent variables
        v := Vars{}
+       title := strings.Replace(strings.Replace(path, "_", " ", -1), "-", " ", -1)
+       v["title"] = strings.ToTitle(title)
+       v["description"] = ""
+
+       // Copy globals (will override title and description for markdown layouts
        for name, value := range globals {
                v[name] = value
        }
 
-       // Override them by default values extracted from file name/path
+       // Add default values extracted from file name/path
        if _, err := os.Stat(filepath.Join(ZSDIR, "layout.amber")); err == nil {
                v["layout"] = "layout.amber"
        } else {
                v["layout"] = "layout.html"
        }
-       title := strings.Replace(strings.Replace(path, "_", " ", -1), "-", " ", -1)
-       v["title"] = strings.ToTitle(title)
-       v["description"] = ""
        v["file"] = path
        v["url"] = path[:len(path)-len(filepath.Ext(path))] + ".html"
        v["output"] = filepath.Join(PUBDIR, v["url"])