smartntml/ts/index.ts

24 lines
597 B
TypeScript
Raw Normal View History

import './instrument/happydom.js';
2022-05-28 15:29:36 +00:00
import * as plugins from './smartntml.plugins.js';
const deesElement = plugins.deesElement;
export {
deesElement
}
2022-05-28 18:03:13 +00:00
export class Smartntml {
2022-05-28 15:29:36 +00:00
constructor() {
}
public async renderTemplateResult(templateResult: plugins.deesElement.TemplateResult, stripCommentsArg = true) {
2022-05-28 15:29:36 +00:00
const element = document.createElement('div');
plugins.deesElement.render(templateResult, element);
2022-05-29 13:02:48 +00:00
let stringResult = element.innerHTML;
if (stripCommentsArg) {
stringResult = stringResult.replace(/<!--(.*?)-->/g, '');
}
return stringResult;
2022-05-28 15:29:36 +00:00
}
}