Skip to content

Instantly share code, notes, and snippets.

@mattiaerre
Last active August 20, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattiaerre/43a396940d063c9206230cbb5bb9d2ac to your computer and use it in GitHub Desktop.
Save mattiaerre/43a396940d063c9206230cbb5bb9d2ac to your computer and use it in GitHub Desktop.
Load the OpenComponents client then render a component.
(() => {
const script = document.createElement('script');
script.type = 'application/javascript';
script.src = '//s3.amazonaws.com/oc-registry-dc/components/oc-client/0.40.7/src/oc-client.min.js';
script.onload = () => {
const html = window.oc.build({
baseUrl: '//oc.registry.dc',
name: 'oc-superman',
version: '1.0.0',
parameters: {
name: 'Clark kent'
}
});
const div = document.createElement('div');
div.innerHTML = html;
const element = div.firstChild;
document.body.appendChild(element);
window.oc.renderUnloadedComponents();
};
document.body.appendChild(script);
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment