{{ $file := .Get "file" }} {{ $filePath := (path.Join "/static/code/" $file ) }} {{ $fileContents := $filePath | readFile }} {{ $lang := .Get "lang" | default "txt" }} {{ $embed := .Get "embed" | default true }} {{ if $embed }} {{ if isset .Params "marker" }} {{ $marker := .Get "marker" }} {{ $regex := printf "(?s).*%s%s%s.*" $marker `(\n)?(?P.*?)(\n\s+)?` $marker }} {{ $fileContents = replaceRE $regex "$inner" $fileContents}} {{ end }} {{ range $key, $value := $.Params }} {{ if hasPrefix $key "replace-key" }} {{ $replace := $value }} {{ $replaceValueParameter := printf "replace-value-%s" (slicestr $key (len "replace-key-")) }}

{{ $replaceValueParameter }}

{{ $replaceWith := index $.Params $replaceValueParameter }} {{ $regex := printf "(?s)%s%s%s" $replace `(\n)?(?P.*?)(\n\s+)?` $replace }} {{ $fileContents = replaceRE $regex $replaceWith $fileContents}} {{ end }} {{ end }} {{ (print "```" $lang "\n" $fileContents "\n```") | markdownify }} {{ end }}