mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-24 01:01:45 +00:00
Rename ReadDir to readDir
To make it consistent with the other template funcs.
This commit is contained in:
parent
153332706a
commit
cea82842f0
2 changed files with 6 additions and 6 deletions
|
@ -15,13 +15,13 @@ weight: 110
|
||||||
## Traversing Local Files
|
## Traversing Local Files
|
||||||
|
|
||||||
Hugo includes a way to traverse local files.
|
Hugo includes a way to traverse local files.
|
||||||
This is done using the 'ReadDir' function.
|
This is done using the 'readDir' function.
|
||||||
|
|
||||||
## Using ReadDir
|
## Using readDir
|
||||||
|
|
||||||
ReadDir takes a single string input that is relative to the root directory of the site. It returns an array of [os.FileInfo](https://golang.org/pkg/os/#FileInfo)
|
readDir takes a single string input that is relative to the root directory of the site. It returns an array of [os.FileInfo](https://golang.org/pkg/os/#FileInfo)
|
||||||
|
|
||||||
Let's create a shortcode to build a file index with links using ReadDir.
|
Let's create a shortcode to build a file index with links using readDir.
|
||||||
|
|
||||||
'fileindex.html'
|
'fileindex.html'
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ Let's create a shortcode to build a file index with links using ReadDir.
|
||||||
{{$dir := .Get "dir"}}
|
{{$dir := .Get "dir"}}
|
||||||
{{ $url := .Get "baseurl" }}
|
{{ $url := .Get "baseurl" }}
|
||||||
|
|
||||||
{{ $files := ReadDir $dir }}
|
{{ $files := readDir $dir }}
|
||||||
{{ range $files }}
|
{{ range $files }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{.Size}}</td>
|
<td>{{.Size}}</td>
|
||||||
|
|
|
@ -1369,7 +1369,7 @@ func init() {
|
||||||
"dateFormat": DateFormat,
|
"dateFormat": DateFormat,
|
||||||
"getJSON": GetJSON,
|
"getJSON": GetJSON,
|
||||||
"getCSV": GetCSV,
|
"getCSV": GetCSV,
|
||||||
"ReadDir": ReadDir,
|
"readDir": ReadDir,
|
||||||
"seq": helpers.Seq,
|
"seq": helpers.Seq,
|
||||||
"getenv": func(varName string) string { return os.Getenv(varName) },
|
"getenv": func(varName string) string { return os.Getenv(varName) },
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue