Mercurial > yakumo_izuru > aya
comparison zs.go @ 36:a88ccfbd4103 draft
fixed variable override order
author | zaitsev.serge |
---|---|
date | Wed, 02 Sep 2015 17:43:31 +0000 |
parents | 0498cb3afc1d |
children | 806ca2102d6b |
comparison
equal
deleted
inserted
replaced
35:0498cb3afc1d | 36:a88ccfbd4103 |
---|---|
97 if err != nil { | 97 if err != nil { |
98 return nil, "", err | 98 return nil, "", err |
99 } | 99 } |
100 s := string(b) | 100 s := string(b) |
101 | 101 |
102 // Copy globals first | 102 // Pick some default values for content-dependent variables |
103 v := Vars{} | 103 v := Vars{} |
104 title := strings.Replace(strings.Replace(path, "_", " ", -1), "-", " ", -1) | |
105 v["title"] = strings.ToTitle(title) | |
106 v["description"] = "" | |
107 | |
108 // Copy globals (will override title and description for markdown layouts | |
104 for name, value := range globals { | 109 for name, value := range globals { |
105 v[name] = value | 110 v[name] = value |
106 } | 111 } |
107 | 112 |
108 // Override them by default values extracted from file name/path | 113 // Add default values extracted from file name/path |
109 if _, err := os.Stat(filepath.Join(ZSDIR, "layout.amber")); err == nil { | 114 if _, err := os.Stat(filepath.Join(ZSDIR, "layout.amber")); err == nil { |
110 v["layout"] = "layout.amber" | 115 v["layout"] = "layout.amber" |
111 } else { | 116 } else { |
112 v["layout"] = "layout.html" | 117 v["layout"] = "layout.html" |
113 } | 118 } |
114 title := strings.Replace(strings.Replace(path, "_", " ", -1), "-", " ", -1) | |
115 v["title"] = strings.ToTitle(title) | |
116 v["description"] = "" | |
117 v["file"] = path | 119 v["file"] = path |
118 v["url"] = path[:len(path)-len(filepath.Ext(path))] + ".html" | 120 v["url"] = path[:len(path)-len(filepath.Ext(path))] + ".html" |
119 v["output"] = filepath.Join(PUBDIR, v["url"]) | 121 v["output"] = filepath.Join(PUBDIR, v["url"]) |
120 | 122 |
121 delim := "\n---\n" | 123 delim := "\n---\n" |