19 lines
862 B
HTML
19 lines
862 B
HTML
{{- $file := .Get "file" -}}
|
|
{{- $codeLang := "" -}}
|
|
{{- $suffix := findRE "(\\.[^.]+)$" $file 1 -}}
|
|
{{- with $suffix -}}
|
|
{{- $codeLang = (index . 0 | strings.TrimPrefix ".") -}}
|
|
{{- end -}}
|
|
{{- with .Get "codeLang" -}}{{- $codeLang = . -}}{{- end -}}
|
|
<div class="code" id="{{ $file | urlize}}">
|
|
{{- with $file -}}
|
|
<div class="filename">{{.}}</div>
|
|
{{- end -}}
|
|
{{- if ne (.Get "copy") "false" -}}
|
|
<button class="copy-btn copy" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="Copy this code."><i class="fas fa-clipboard"></i> Copy</button>
|
|
{{- end -}}
|
|
<div class="code-content" {{ with .Get "download" }}id="{{ . }}"{{ end }}>
|
|
{{ if .Get "nocode" }}{{ $.Inner }}{{ else }}{{ with $codeLang }}{{- highlight $.Inner . "" | -}}{{ else }}<pre><code>{{- .Inner | string -}}</code></pre>{{ end }}{{ end }}
|
|
</div>
|
|
</div>
|