Skip to content

Instantly share code, notes, and snippets.

@sardinecan
Created June 23, 2022 05:56
Show Gist options
  • Save sardinecan/390e19604d436033a8817eaacd0e004b to your computer and use it in GitHub Desktop.
Save sardinecan/390e19604d436033a8817eaacd0e004b to your computer and use it in GitHub Desktop.
HTML from JSON 2 HTML with Svelte Kit
<script>
import { onMount } from 'svelte' ;
let container;
let str = {
"foo": "<h1>Hello World</h1><p>Hello World in a paragraph</p>"
};
onMount(() => {
let newInnerHTML = str.foo
container.innerHTML = newInnerHTML;
});
function makeStrong() {
let newInnerHTML = str.foo;
container.innerHTML = newInnerHTML;
}
</script>
<div bind:this={container}/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment