The most simple template factory in the world!
Turn any <template>
into a HTMLElement
in a breeze.
using npm
npm install @devlop/kobolt
Kobolt can automatically replace placeholders in your template using the format {{ placeholder }}
.
<template>
<div data-description="{{ title }}">
<h1 id="{{ id }}">{{ title }}</h1>
</div>
</template>
import kobolt from '@devlop/kobolt';
const templateElement = document.querySelector('template');
const outputElement = kobolt(templateElement, {
// pass a key value object with any placeholders that should be replaced.
'title': 'Kobolt',
'id': 'Co',
});
console.log(outputElement.outerHTML);
// <div data-description="Kobolt">
// <h1 id="Co">Kobolt</h1>
// </div>