fime/themes/ace-documentation/layouts/shortcodes/code.html

29 lines
845 B
HTML
Raw Permalink Normal View History

2022-09-28 19:20:15 +00:00
{{ .Scratch.Set "content" "" }}
{{ .Scratch.Set "identifier" "" }}
{{ $identifier := "" }}
{{ $filepath := .Get "file"}}
{{ if ($filepath) }}
{{ .Scratch.Set "content" ($filepath | readFile) }}
{{ .Scratch.Set "identifier" (first 10 (md5 (.Scratch.Get "content"))) }}
{{ else }}
{{ .Scratch.Set "content" .Inner }}
{{ .Scratch.Set "identifier" (first 10 (md5 .Inner)) }}
{{ end}}
{{ $lang := .Get "lang" }}
<div class="position-relative">
<div class="position-absolute" style="right:0;">
<button class="btn btn-light" data-clipboard-target="#{{printf "clipboard_%s" (.Scratch.Get "identifier") }}">
Copy
</button>
</div>
<div id="{{printf "clipboard_%s" (.Scratch.Get "identifier") }}">
{{ (print "```" $lang "\n" (.Scratch.Get "content") "\n```") | markdownify }}
</div>
</div>