Connect (ExpressJS) middleware for serving pug files as static html
npm install express-pug-static
Assume the following structure of your project:
/views
/partials
/file.pug
Let's make pug files from /views/partials
web accessible:
var pugStatic = require('express-pug-static');
app = express();
app.configure(function() {
app.use(pugStatic({
baseDir: path.join(__dirname, '/views/partials'),
baseUrl: '/partials',
maxAge: 86400,
pug: { pretty: true }
}));
});
var pugStatic = require('express-pug-static');
app = express();
app.use(pugStatic({
baseDir: path.join(__dirname, '/views/partials'),
baseUrl: '/partials',
maxAge: 86400,
pug: { pretty: true }
}));
Now, if you start your web server and request /partials/file.html
in browser you
should be able see the compiled pug template.