github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/layouts/shortcodes/code.html (about)

     1  {{ $file := .Get "file" }}
     2  {{ $.Scratch.Set "codeLang" "" }}
     3  {{ $suffix := findRE "(\\.[^.]+)$" $file 1 }}
     4  {{ with  $suffix }}
     5  {{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }}
     6  {{ end }}
     7  {{ with .Get "codeLang" }}{{ $.Scratch.Set "codeLang" . }}{{ end }}
     8  {{ if eq (.Scratch.Get "codeLang") "html"}}
     9  {{ $.Scratch.Set "codeLang" "go-html-template" }}
    10  {{ end }}
    11  <div class="code relative" id="{{ $file | urlize}}">
    12  	{{- with $file -}}
    13  		<div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div>
    14  	{{- end -}}
    15  
    16  	{{ if ne (.Get "copy") "false" }}
    17  		<button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button">
    18  		</button>
    19  		{{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
    20  	{{end}}
    21  	<div class="code-copy-content nt3" {{with .Get "download"}}id="{{.}}"{{end}}>
    22  	  	{{ if  .Get "nocode" }}{{ $.Inner }}{{ else }}{{ with $.Scratch.Get "codeLang" }}{{- highlight $.Inner . "" | -}}{{ else }}<pre><code>{{- .Inner | string -}}</code></pre>{{ end }}{{ end }}
    23  	</div>
    24  
    25  </div>