1.0.0 • Published 1 year ago

@isekaimaouyoki-sama/fastify-pug v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

@fastify/pug

This is a small wrapper around pug.

Install

npm i @fastify/pug

Usage

Easy to use require/import this plugin as below

const path = require('path')
const fastify = require('fastify')()

fastify.register(
  require('@fastify/pug'),
  { 
    // root directory for view
    rootDir: path.join(__dirname, "views")
  }
)

fastify.get("/", async function(request, reply) {
  reply.renderer(
    'home.pug', // path to pug template
    { name: 'toni' } // data to pass into template
  )
})

fastify.listen({ port: 3000 }, err => {
  if (err) throw err
})
1.0.0

1 year ago