BREAKING CHANGE(improved the loading of the environment. Can now be used in sync environments.): update
This commit is contained in:
32
ts/index.ts
32
ts/index.ts
@@ -1,35 +1,19 @@
|
||||
import './instrument/happydom.js';
|
||||
import * as plugins from './smartntml.plugins.js';
|
||||
import * as deesElement from '@designestate/dees-element';
|
||||
|
||||
const deesElement = plugins.deesElement;
|
||||
export {
|
||||
deesElement
|
||||
}
|
||||
|
||||
export class Smartntml {
|
||||
// STATIC
|
||||
public static async create() {
|
||||
const smartntml = new Smartntml();
|
||||
return smartntml;
|
||||
}
|
||||
|
||||
private static smartntmlSingletonDeferred: plugins.smartpromise.Deferred<Smartntml>;
|
||||
public static async createSingleton() {
|
||||
if (this.smartntmlSingletonDeferred) {
|
||||
return this.smartntmlSingletonDeferred.promise;
|
||||
}
|
||||
this.smartntmlSingletonDeferred = plugins.smartpromise.defer();
|
||||
const smartntmlInstance = await this.create();
|
||||
this.smartntmlSingletonDeferred.resolve(smartntmlInstance);
|
||||
return this.smartntmlSingletonDeferred.promise;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
private render = deesElement.render;
|
||||
public html = deesElement.html;
|
||||
public unsafeHTML = deesElement.unsafeHTML;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public async renderTemplateResult(templateResult: deesElement.TemplateResult, stripCommentsArg = true) {
|
||||
public async renderTemplateResult(templateResult: plugins.deesElement.TemplateResult, stripCommentsArg = true) {
|
||||
const element = document.createElement('div');
|
||||
this.render(templateResult, element);
|
||||
plugins.deesElement.render(templateResult, element);
|
||||
let stringResult = element.innerHTML;
|
||||
if (stripCommentsArg) {
|
||||
stringResult = stringResult.replace(/<!--(.*?)-->/g, '');
|
||||
|
||||
Reference in New Issue
Block a user