smartntml/ts/index.ts

33 lines
711 B
TypeScript
Raw Permalink Normal View History

2022-05-28 15:29:36 +00:00
import * as plugins from './smartntml.plugins.js';
import type * as litTypes from 'lit';
export class Smartntml {
// STATIC
public static async createAndInit() {
const smartntml = new Smartntml();
await smartntml.init();
return smartntml;
}
// INSTANCE
render: typeof litTypes.render;
html: typeof litTypes.html;
constructor() {
this.init();
}
public async init() {
const lit = await import('lit');
this.render = lit.render;
this.html = lit.html;
}
public async renderTemplateResult(templateResult: litTypes.TemplateResult) {
const element = document.createElement('div');
this.render(templateResult, element);
return element.innerHTML;
}
}