{{ $error := false -}} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "file" "args" .Params) }} {{ errorf "Invalid arguments: %s" .Position -}} {{ $error = true }} {{ end }} {{- $basePath := .Site.Params.docs.basePath -}} {{- $file := .Get "path" | default "" -}} {{- if hasPrefix $file "./" -}} {{- $file = path.Clean $file -}} {{- else -}} {{- $file = path.Join $basePath (path.Clean $file) -}} {{- end -}} {{- $extension := strings.TrimLeft "." (path.Ext $file) }} {{- $lang := .Get "lang" | default $extension -}} {{- $id := .Get "id" | default (printf "file-collapse-%d" .Ordinal) -}} {{ $show := .Get "show" | default true -}} {{ $full := .Get "full" | default true -}} {{- $class := .Get "class" | default "" -}} {{- if not $error -}} {{- /* Force-check if the file exists */ -}} {{ $tmp := os.Stat $file }} {{- $content := readFile $file -}}
{{- highlight (trim $content "\r\n") $lang "" -}}
{{- end -}}