2.0.2 • Published 8 months ago

@hoth/view v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@hoth/view

Usage

  1. register view plugin in app.ts
import path from 'path';
import view from '@hoth/view';
import ejs from 'ejs';
import type {FastifyInstance} from 'fastify';
import type {AppConfig} from '@hoth/app-autoload';

export default async function main(fastify: FastifyInstance, config: AppConfig) {
    await fastify.register(view, {
        engine: {
            ejs,
        },
        renderOnly: true,
        templatesDir: path.join(config.dir, 'view'),
    });
    return fastify;
}
  1. use reply.render to render view
const html = await reply.render('index.tpl', {
    name: 'world',
});

reply.send(html);
2.0.2

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.3.2

2 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.0

4 years ago