diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html index 2ee20b1eb..eafc02e6b 100644 --- a/layouts/shortcodes/code.html +++ b/layouts/shortcodes/code.html @@ -1,12 +1,12 @@ {{ $file := .Get "file" }} -{{ $.Scratch.Set "codeLang" "" }} +{{ $codeLang := "" }} {{ $suffix := findRE "(\\.[^.]+)$" $file 1 }} {{ with $suffix }} -{{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }} +{{ $codeLang = (index . 0 | strings.TrimPrefix ".") }} {{ end }} -{{ with .Get "codeLang" }}{{ $.Scratch.Set "codeLang" . }}{{ end }} -{{ if eq (.Scratch.Get "codeLang") "html"}} -{{ $.Scratch.Set "codeLang" "go-html-template" }} +{{ with .Get "codeLang" }}{{ $codeLang = . }}{{ end }} +{{ if eq $codeLang "html"}} +{{ $codeLang = "go-html-template" }} {{ end }}
{{- .Inner | string -}}
{{ end }}{{ end }}
+ {{ if .Get "nocode" }}{{ $.Inner }}{{ else }}{{ with $codeLang }}{{- highlight $.Inner . "" | -}}{{ else }}{{- .Inner | string -}}
{{ end }}{{ end }}