{{/* Creates a copy to clipboard button above each code block that switches between a copy and copied state by controlling the buttons visibility with js. If the code block is marked as citation style, placeholders inside the citation text will be replaced and the code block will be styled as a citation block. Otherwise, rendered as regular code block. Date accessed needs to be set by JS, hence the span element. */}} {{- $content := .Inner | safeHTML -}} {{- $style := index .Attributes "style" | default "code" -}}
{{ if eq $style "citation" }} {{ $year := now.Year }} {{ $date := now.Format "January 2, 2006" }} {{/* Replace citation text placeholders */}} {{ $version := partial "GetVersion.html" }} {{ $portalVersion := $version.tag | default "X.X.X" | strings.TrimPrefix "v" }} {{ $content := replace $content "DATE_ACCESSED" "" }} {{ $content := replace $content "YEAR" $year }} {{ $content := replace $content "VERSION_NUMBER" $portalVersion }}
{{- strings.TrimSpace $content | markdownify -}}
{{ else }}
{{ $content }}
{{ end }} {{ .Page.Store.Set "needsClipboardJS" true }} {{ .Page.Store.Set "needsDate" true }}