1.1.0 • Published 8 years ago

@donotjs/donot-transform-pug v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

donot-transform-pug

Build Status

pug compiler and renderer for donot.

Usage

Using the pug donot transform plug-in is pretty easy.

var http = require('http'),
    donot = require('donot'),
    PugTransform = require('donot-transform-pug');

var server = http.createServer(donot(__dirname + '/public', {
	transforms: [ new PugTransform({
		// Options
	}) ]
}));

server.listen(8000);

Now .pug files in the /public folder will automatically be compiled, rendered and served as .html files.

Locals

Providing locals for pug renderings is possible using the renderCallback option.

An example on how to use this below (here with Express).

var express = require('express'),
    donot = require('donot'),
    PugTransform = require('donot-transform-pug');

var app = express();

app.get('/index.html', function(req, res, next) {
	req.options = {
		// pug locals
	};
	next();
});

app.use(donot(__dirname + '/public', {
	transforms: [ new PugTransform({
		renderCallback: function(req) {
			return req.options;
		}
	}) ]
}));

In the above example the renderCallback is called whenever pug is rendering a template. The app.get('/index.html'... route sets the req.options - which is then returned for pug to use in the callback.

License

MIT

1.1.0

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago