Closed sirenkovladd closed 10 months ago
Call reply.view with raw text or a callback function
Projects can use precompiled templates
Projects can use a generated template that can be received from an external source, you can avoid saving the template to a file
fastify.get('/', async (req, reply) => { const rawTemplate = await someRequestOrQuery(req) const someData = await getSomeData(req) reply.view({ raw: rawTemplate }, someData) })
fastify.get('/', async (req, reply) => { const rawTemplate = await prepareHbsTemplate(req) const template = hbs.template(rawTemplate) // typeof template === 'function' const someData = await getSomeData(req) reply.view(template, someData, { layout: someLayout }) })
Prerequisites
🚀 Feature Proposal
Call reply.view with raw text or a callback function
Motivation
Projects can use precompiled templates
Projects can use a generated template that can be received from an external source, you can avoid saving the template to a file
Example