funcFileStat returns Stat of a filename
(filename string)
| 437 | |
| 438 | // funcFileStat returns Stat of a filename |
| 439 | func (c TemplateContext) funcFileStat(filename string) (fs.FileInfo, error) { |
| 440 | if c.Root == nil { |
| 441 | return nil, fmt.Errorf("root file system not specified") |
| 442 | } |
| 443 | |
| 444 | file, err := c.Root.Open(path.Clean(filename)) |
| 445 | if err != nil { |
| 446 | return nil, err |
| 447 | } |
| 448 | defer file.Close() |
| 449 | |
| 450 | return file.Stat() |
| 451 | } |
| 452 | |
| 453 | // funcHTTPError returns a structured HTTP handler error. EXPERIMENTAL; SUBJECT TO CHANGE. |
| 454 | // Example usage: `{{if not (fileExists $includeFile)}}{{httpError 404}}{{end}}` |