@aptoma/dredition-layout

Functions to render a DrEdition layout

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@aptoma/dredition-layout
Minified + gzip package size for @aptoma/dredition-layout in KB

Readme

DrEdition layout

Functions to render a DrEdition layout

Installation

npm install @aptoma/dredition-layout

Usage

A single template string

const layout = require('@aptoma/dredition-layout');

const groups = [
    {title: 'Group 1'},
    {title: 'Group 2'}
];

const templateString = `<div>
    {% for group in groups %}
        <h1>{{ group.title }}</h1>
    {% endfor %}
</div>`;

layout.renderString(template, data)
    .then((html) => {
        console.log('Result:', html);
    });

JSON/object templates

const templateObject = {
    'parent.html': '<h1>Groups</h1>{% block groups %}{% endblock %}',
    'index.html': `
{% extends 'parent.html'}

{% block groups %}
    <div>
        {% for group in groups %}
            <h1>{{ group.title }}</h1>
        {% endfor %}
    </div>
{% endblock %}`,
};

layout.renderJsonTemplate(template, data)
    .then((html) => {
        console.log('Result:', html);
    });

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.