31 lines
847 B
Handlebars
31 lines
847 B
Handlebars
import { lazyLoadComponent, createComponents } from '../engine/web/common/webpack/assets/components/bootstrap';
|
|
|
|
async function loadComponents(root) {
|
|
let component, name;
|
|
{{#each components }}
|
|
await lazyLoadComponent(root, "{{ this.class }}", {{{ this.selector }}},
|
|
{{#if this.version_js }}
|
|
async function(){return await import("{{ this.file_js }}");}
|
|
{{else}}
|
|
null
|
|
{{/if}},
|
|
{{#if this.version_css }}
|
|
async function(){return await import("{{ this.file_css }}");}
|
|
{{else}}
|
|
null
|
|
{{/if}}
|
|
);
|
|
{{/each}}
|
|
};
|
|
|
|
export async function initComponents(root) {
|
|
await loadComponents(root);
|
|
createComponents(document);
|
|
}
|
|
|
|
const _listener = () => initComponents(document);
|
|
|
|
_listener();
|
|
document.addEventListener('DOMContentLoaded', _listener);
|
|
document.addEventListener('wpj-products-loaded', _listener);
|