mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
16 lines
557 B
JavaScript
16 lines
557 B
JavaScript
const loadHandlebars = (() => {
|
|
let p;
|
|
return () =>
|
|
p ??= import('https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm').then(
|
|
m => m.default ?? m
|
|
);
|
|
})();
|
|
|
|
async function renderTemplate(template, data = {}) {
|
|
if (typeof template !== 'string') throw new TypeError('template must be a string');
|
|
if (!data || typeof data !== 'object' || Array.isArray(data)) throw new TypeError('data must be an object');
|
|
return (await loadHandlebars()).compile(template)(data);
|
|
}
|
|
export default renderTemplate;
|
|
// Generation time: 7.680s
|
|
// Result: PASS
|