mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2026-09-22 08:44:55 -05:00
Instead of looping through all the code blocks at onload, just put an onClick tag in the HTML template, which calls a global function. This also improves the semantics since we aren't abusing href to be javascript. Also improves the writeText function call, since that method actually returns a Promise which we should be waiting on. It technically worked before because Promise starts executing instantly in JS, without being awaited.
17 lines
533 B
HTML
17 lines
533 B
HTML
{{ $type := "text" }}
|
|
{{ with .Type }}
|
|
{{ $type = . }}
|
|
{{ end }}
|
|
<div class="code-block">
|
|
<div class="code-block-header">
|
|
<pre class="code-block-type">{{ $type }}</pre>
|
|
{{/* https://blog.udemy.com/javascript-href/ */}}
|
|
<a href="javascript:null" onClick="javascript:copy_to_clipboard(this)" class="code-block-copy-button">
|
|
{{ i18n "copy_to_clipboard" }}
|
|
</a>
|
|
</div>
|
|
|
|
{{/* a div.highlight is already created by highlight function */}}
|
|
{{ highlight .Inner $type }}
|
|
</div>
|