cupper-hugo-theme/themes/inclusive-pattern-docs/layouts/shortcodes/demo.html

21 lines
746 B
HTML
Raw Normal View History

2017-06-20 10:53:54 +02:00
{{ $uniq := .Inner | htmlEscape | base64Encode | truncate 15 "" }}
<div class="demo-container">
<div id="demo-{{ $uniq }}">
</div>
<template id="template-{{ $uniq }}">
2017-06-20 15:01:15 +02:00
{{ .Inner }}
2017-06-20 10:53:54 +02:00
</template>
<script>
(function() {
var root = document.getElementById('demo-{{ $uniq }}');
root.attachShadow({mode: 'open'});
var template = document.getElementById('template-{{ $uniq }}');
var script = template.content.querySelector('script');
2017-06-22 18:13:17 +02:00
if (script) {
script.textContent = `(function() { var demo = document.getElementById(\'demo-{{ $uniq }}\').shadowRoot; ${script.textContent} })()`
}
2017-06-20 10:53:54 +02:00
root.shadowRoot.appendChild(document.importNode(template.content, true));
})();
</script>
</div>