Deprecated. Use point of view instead.
A plugin for fastify that adds support for the template engine pug.
npm install fastify-pug
const fastify = require('fastify');
const fastifyPug = require('fastify-pug');
const app = fastify();
app.register(fastifyPug, {views: 'views'});
app.get('/', (request, reply) => {
reply.render('template.pug');
});
app.listen(3000, (error) => {
if (error) throw error
})
views
- the relative path to the folder containing the views.fallbackViews
(optional) - a fallback directory for the views.filename
(optional) - for handling relative includes. Pass in a function like (view: string) =>src/${view}
Renders the template from the relative path view
. Allows to pass variables to the template via the locals
object.