{{- /* Renders syntax highlighted code. @param {bool} [copy=false] If true, display a copy to clipboard button. @param {string} [file] The file name to display above the rendered code. @param {string} [lang] The code language of the inner content. @returns {template.HTML} */}} {{- /* Get parameters. */}} {{- $copy := false }} {{- if in (slice "false" false 0) (.Get "copy") }} {{- $copy = false }} {{- else if in (slice "true" true 1) (.Get "copy")}} {{- $copy = true }} {{- end }} {{- $file := or (.Get "file") " " }} {{- $lang := or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }} {{- /* Use the go-html-template Chroma lexer for HTML. */}} {{- if eq $lang "html" }} {{- $lang = "go-html-template" }} {{- end }} {{- /* Render. */}}
{{ $file | htmlUnescape }}
{{- if $copy }} {{- end }}
{{- highlight (trim .Inner "\n\r") $lang }}