0.4.1 • Published 11 months ago

@yikesable/fastify-async-htm-to-string v0.4.1

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

Fastify Async Htm To String

Fastify plugin for async-htm-to-string, which renders a htm tagged template asyncly into a string.

neostandard javascript style Module type: ESM Types in JS Follow @voxpelli@mastodon.social

Usage

To render simple HTML fragment

import { fastify } from 'fastify';

const app = fastify();

app.register(import('@yikesable/fastify-async-htm-to-string'));

app.get('/', (_request, reply) => {
  reply.render(html`<div>Hi</div>`);
});

To render full HTML page

import { fastify } from 'fastify';

const app = fastify();

const htmlHead = async () => '<!DOCTYPE html><html lang="en">' + await app.render(html`
  <head>
    <meta charset="utf-8" />
    <title>Hello World</title>
  </head>
`);

app.register(import('@yikesable/fastify-async-htm-to-string'), { htmlHead });

app.get('/', (_request, reply) => {
  reply.renderPage(html`<div>Hi</div>`);
});

See also

0.4.1

11 months ago

0.4.0

11 months ago

0.3.1

12 months ago

0.3.0

12 months ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago