0.0.1-beta.20 • Published 9 months ago

async-nunjucks v0.0.1-beta.20

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

async-nunjucks

Introduction

use nunjucks with ES6 Promise!

Installation and Usage

npm install async-nunjucks

Rendering template asynchronously

import { AsyncNunjucks } from 'async-nunjucks';

const TEMPLATE_DIR = 'templates/';
const TEMPLATE_FILENAME = 'demo.njk';

const engine = new AsyncNunjucks({
  loader: [TEMPLATE_DIR],
  configure: {
    autoescape: false,
  },
});

async function welcome() {
  // rendering asynchronously
  const result = await engine.renderPromise(TEMPLATE_FILENAME, {
    name: 'Max10240',
  });

  console.log('2. render result:', result);
}


// Go!
welcome();

Promise.resolve().then(() =>
  console.log(`1. i am faster than "renderPromise", it won't block me!`)
);

A live example can bee seen at: stackblitz example

0.0.1-beta.20

9 months ago

0.0.1-beta.18

11 months ago

0.0.1-beta.17

11 months ago

0.0.1-beta.19

9 months ago

0.0.1-beta.14

11 months ago

0.0.1-beta.13

11 months ago

0.0.1-beta.16

11 months ago

0.0.1-beta.15

11 months ago

0.0.1-beta.12

11 months ago

0.0.1-beta.11

11 months ago

0.0.1-beta.10

11 months ago

0.0.1-beta.9

11 months ago

0.0.1-beta.4

11 months ago

0.0.1-beta.2

11 months ago

0.0.1-beta.1

11 months ago