<div class="chart"> {{ $id := delimit (shuffle (seq 1 9)) "" }} <canvas id="{{ $id }}"></canvas> <script type="text/javascript"> window.addEventListener("DOMContentLoaded", (event) => { const ctx = document.getElementById("{{ $id }}"); const chart = new Chart(ctx, { {{ .Inner | safeJS }} }); }); </script> </div>