nal

nunjucks-async-loader

Asynchronous loader templates nunjucks

Showing:

Popularity

Downloads/wk

1.1K

GitHub Stars

2

Maintenance

Last Commit

1yr ago

Contributors

0

Package

Dependencies

3

Size (min+gzip)

24.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

nunjucks-async-loader

Asynchronous loader templates nunjucks.

Why You Need?

nunjucks.FileSystemLoader loads templates synchronously. See this issue.

Installation

$ npm install nunjucks-async-loader --save

Usage

const express = require('express');
const nunjucks = require('nunjucks');
const nunjucksAsyncLoader = require('nunjucks-async-loader');

const app = express();
const isDev = app.get('env') === 'development';

const loader = new nunjucksAsyncLoader('views', {
    watch: isDev, // (default: false) reload templates when they are changed.
    noCache: isDev // (default: false) never use a cache and recompile templates each time.
});

const env = new nunjucks.Environment(loader);

env.express(app);


app.get('/', function(req, res) {
    res.render('index.html');
});

app.listen(3000);

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100