smartntml/ts/index.ts

24 lines
624 B
TypeScript
Raw Permalink Normal View History

import './instrument/happydom.js';
2024-05-28 08:40:38 +00:00
2022-05-28 15:29:36 +00:00
import * as plugins from './smartntml.plugins.js';
2024-05-27 22:28:33 +00:00
import * as deesElement from '@design.estate/dees-element';
2023-05-01 11:03:55 +00:00
export { deesElement };
2022-05-28 18:03:13 +00:00
export class Smartntml {
2023-05-01 11:03:55 +00:00
constructor() {}
2022-05-28 15:29:36 +00:00
2023-05-01 11:03:55 +00:00
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
}
}