</tr>
{.repeated section @}
<tr>
- <td align="left"><a href="{Name|html}">{Name|html}</a></td>
+ <td align="left"><a href="{Name|html}{@|dir/}">{Name|html}{@|dir/}</a></td>
<td></td>
<td align="right">{Size|html}</td>
<td></td>
}
+// Template formatter for "dir/" format.
+func dirslashFmt(w io.Writer, x interface{}, format string) {
+ if x.(*os.Dir).IsDirectory() {
+ w.Write([]byte{'/'})
+ }
+}
+
+
var fmap = template.FormatterMap{
"": textFmt,
"html": htmlFmt,
"infoSnippet": infoSnippetFmt,
"padding": paddingFmt,
"time": timeFmt,
+ "dir/": dirslashFmt,
}
return
}
+ // if it begins with "<!DOCTYPE " assume it is standalone
+ // html that doesn't need the template wrapping.
+ if bytes.HasPrefix(src, strings.Bytes("<!DOCTYPE ")) {
+ c.Write(src)
+ return
+ }
+
// if it's the language spec, add tags to EBNF productions
if strings.HasSuffix(path, "go_spec.html") {
var buf bytes.Buffer
return
}
+ for _, d := range list {
+ if d.IsDirectory() {
+ d.Size = 0
+ }
+ }
+
var buf bytes.Buffer
if err := dirlistHTML.Execute(list, &buf); err != nil {
log.Stderrf("dirlistHTML.Execute: %s", err)