From 07e9963f66e288ad5a2aa89ee9188e34c331c17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 31 Mar 2016 23:16:42 +0200 Subject: [PATCH] docs: Add doc and a test for readDir Fixes #2009 --- content/templates/functions.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/content/templates/functions.md b/content/templates/functions.md index fe0f2e251..0573978de 100644 --- a/content/templates/functions.md +++ b/content/templates/functions.md @@ -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!`: