lit-html-template

1.0.1 • Public • Published

Example:

post.html.js

const html = require('lit-html-template');
const post = function (data) {
    return html`
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>${data.title}</title>
        </head>

        <body>
            <h2>
                <a href="/">首页</a>
            </h2>
            <div>
                ${data.content}
            </div>
        </body>
    </html>
    `;
}

module.exports = post;

post.controller.js

app.get('/:slug/', async (request, reply) => {
        const res = await db.get(`SELECT * FROM posts WHERE slug=? LIMIT 1`, [request.params.slug]);
        reply
            .code(200)
            .header('Content-Type', 'text/html; charset=utf-8')
            .send(view.post(res))
    })

Readme

Keywords

none

Package Sidebar

Install

npm i lit-html-template

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

1.3 kB

Total Files

3

Last publish

Collaborators

  • saminn.liu