Hi!, my name is {{ name }}
{{ shortBio }}
Partial Polyfill for the Template Instantiation Proposal
npm install template-instantiation-polyfillA partial polyfill for the [Template Instantiation Proposal]()
```
npm i -S template-instantiation-polyfill
` {{ shortBio }}html
Hi!, my name is {{ name }}
``ts
import 'template-instantiation-polyfill';
const template =
document.getElementById
const handleAsJson =
(x: Response) =>
x.handleAsJson();
document.querySelector('button').addEventListener('click', async function() {
const userId = new URLSearchParams(location.search).get('userId');
const { name, picture, shortBio } = await fetch(/users/${userId}).then(handleAsJson);
if (template.instance)
template.instance.update({ name, picture, shortBio })
else
document.body.appendChild(template.createInstance({ name, picture, shortBio }))
});
``
Must appreciation for prior art by @Jamesernator.
Thanks to Ryosuke Niwa for championing the proposal.