demo.html 746 B

1234567891011121314151617181920
  1. {{ $uniq := .Inner | htmlEscape | base64Encode | truncate 15 "" }}
  2. <div class="demo-container">
  3. <div id="demo-{{ $uniq }}">
  4. </div>
  5. <template id="template-{{ $uniq }}">
  6. {{ .Inner }}
  7. </template>
  8. <script>
  9. (function() {
  10. var root = document.getElementById('demo-{{ $uniq }}');
  11. root.attachShadow({mode: 'open'});
  12. var template = document.getElementById('template-{{ $uniq }}');
  13. var script = template.content.querySelector('script');
  14. if (script) {
  15. script.textContent = `(function() { var demo = document.getElementById(\'demo-{{ $uniq }}\').shadowRoot; ${script.textContent} })()`
  16. }
  17. root.shadowRoot.appendChild(document.importNode(template.content, true));
  18. })();
  19. </script>
  20. </div>