mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
cb89ae63e9
commit
c2277fcbc1
2 changed files with 11 additions and 0 deletions
|
@ -337,6 +337,15 @@ e.g.
|
|||
{{ end }}
|
||||
|
||||
## Files
|
||||
|
||||
### readDir
|
||||
|
||||
Gets a directory listing from a directory relative to the current project working dir.
|
||||
|
||||
So, If the project working dir has a single file named `README.txt`:
|
||||
|
||||
`{{ range (readDir ".") }}{{ .Name }}{{ end }}` → "README.txt"
|
||||
|
||||
### readFile
|
||||
Reads a file from disk and converts it into a string. Note that the filename must be relative to the current project working dir.
|
||||
So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`:
|
||||
|
|
|
@ -121,6 +121,7 @@ safeURL: {{ "http://gohugo.io" | safeURL | safeURL }}
|
|||
safeJS: {{ "(1*2)" | safeJS | safeJS }}
|
||||
plainify: {{ plainify "Hello <strong>world</strong>, gophers!" }}
|
||||
readFile: {{ readFile "README.txt" }}
|
||||
readDir: {{ range (readDir ".") }}{{ .Name }}{{ end }}
|
||||
`
|
||||
expected := `chomp: <p>Blockhead</p>
|
||||
dateFormat: Wednesday, Jan 21, 2015
|
||||
|
@ -166,6 +167,7 @@ safeURL: http://gohugo.io
|
|||
safeJS: (1*2)
|
||||
plainify: Hello world, gophers!
|
||||
readFile: Hugo Rocks!
|
||||
readDir: README.txt
|
||||
`
|
||||
|
||||
var b bytes.Buffer
|
||||
|
|
Loading…
Reference in a new issue