summaryrefslogtreecommitdiffstats
path: root/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html')
-rw-r--r--docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html35
1 files changed, 29 insertions, 6 deletions
diff --git a/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html b/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html
index f777abe26..de8083443 100644
--- a/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html
+++ b/docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/readfile.html
@@ -1,6 +1,29 @@
-{{$file := .Get "file"}}
-{{- if eq (.Get "markdown") "true" -}}
-{{- $file | readFile | markdownify -}}
-{{- else -}}
-{{ $file | readFile | safeHTML }}
-{{- end -}} \ No newline at end of file
+{{- $highlight := or (.Get "highlight") "" }}
+
+{{- $markdown := false }}
+{{- if in (slice "false" false 0) (.Get "markdown") }}
+ {{- $markdown = false }}
+{{- else if in (slice "true" true 1) (.Get "markdown") }}
+ {{- $markdown = true }}
+{{- end }}
+
+{{- with .Get "file" }}
+ {{- if os.FileExists . }}
+ {{- with os.ReadFile . }}
+ {{- $content := trim . "\n\r" }}
+ {{- if $markdown }}
+ {{- $content | markdownify }}
+ {{- else if $highlight }}
+ {{- highlight $content $highlight }}
+ {{- else }}
+ {{- $content | safeHTML }}
+ {{- end }}
+ {{- else }}
+ {{- errorf "The %q shortcode was unable to read %q. See %s" $.Name . $.Position }}
+ {{- end }}
+ {{- else }}
+ {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
+ {{- end }}
+{{- else }}
+ {{- errorf "The %q shortcode requires a 'file' parameter. See %s" $.Name $.Position }}
+{{- end }}