nunjucks-async-loader
Asynchronous loader templates nunjucks
Last updated a year ago by pkolt .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install nunjucks-async-loader 
SYNC missed versions from official npm registry.

nunjucks-async-loader Build Status

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

Maintainers (1)
Downloads
Today 0
This Week 1
This Month 8
Last Day 0
Last Week 5
Last Month 108
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |