You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
869 B

import * as Eta from 'eta'
import view from '@fastify/view'
import fastifyPlugin from 'fastify-plugin'
import path from 'path'
import { asset } from './etaHelpers.js'
function etaPlugin(fastify, options, next) {
fastify.register(view, {
engine: {
eta: Eta
},
root: path.join(path.resolve(), '/../frontend/views'),
extname: '.eta',
// adding function to templates
defaultContext: {
asset: asset
},
options: {
tags: [ '{{', '}}' ],
includeViewExtension: true,
parse: {
exec: "#",
interpolate: "",
raw: "!"
},
useWith: true,
async: true
}
})
next()
}
export default fastifyPlugin(etaPlugin, {
fastify: '4.x',
name: 'etaPlugin'
})