docs: add documentation for fileExists and fileStat template functions (#7700)

This commit is contained in:
Steffen Busch 2026-05-11 20:23:58 +02:00 committed by GitHub
parent 0fab9f0f7d
commit 4ba16fe82c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -162,6 +162,25 @@ func init() {
// {{listFiles "/mydir"}}
// ```
//
// ##### `fileExists`
//
// Returns true if the given file name, relative to the template context's file root,
// can be opened successfully.
//
// ```
// {{fileExists "path/to/file.html"}}
// ```
//
// ##### `fileStat`
//
// Returns [FileInfo](https://pkg.go.dev/io/fs#FileInfo) using [Stat](https://pkg.go.dev/io/fs#Stat)
// on the given file name, relative to the template context's file root.
//
// ```
// {{$css := fileStat "css/style.css" -}}
// <link rel="stylesheet" href="/css/style.css?v={{ $css.ModTime.Unix }}">
// ```
//
// ##### `markdown`
//
// Renders the given Markdown text as HTML and returns it. This uses the