Skip to content
/ kobolt Public

The most simple template factory in the world!

License

Notifications You must be signed in to change notification settings

devlop/kobolt

Repository files navigation

Latest Stable Version License

kobolt

The most simple template factory in the world!

Turn any <template> into a HTMLElement in a breeze.

Installing

using npm

npm install @devlop/kobolt

Placeholders

Kobolt can automatically replace placeholders in your template using the format {{ placeholder }}.

Usage

<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>