Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vantagedesign/ace-documentation.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/shortcodes/code.html')
-rw-r--r--layouts/shortcodes/code.html28
1 files changed, 28 insertions, 0 deletions
diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html
new file mode 100644
index 0000000..5d8a778
--- /dev/null
+++ b/layouts/shortcodes/code.html
@@ -0,0 +1,28 @@
+{{ .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>
+
+
+