4.0.0 • Published 7 months ago

@toisu/handlebars v4.0.0

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

toisu-handlebars

@toisu/handlebars is a handlebars wrapper for the TOISU! server micro-framework.

install

To install toisu-handlebars into your project, use:

npm install @toisu/handlebars

usage

import http from 'http';
import Toisu from '@toisu/toisu';
import toisuHandlebars from '@toisu/handlebars';
import dbModule from './a-db-module';

const template = `
  <!doctype html>
  <html>
    <head><title>Hello, world!</title></head>
    <body>{{bodyContent}}</body>
  </html>
`;

const app = new Toisu();

// Put some template data on the context.
app.use(async function () {
  const bodyContent = await dbModule.get();

  this.set('templateData', { bodyContent });
});

// toisu handlebars compiles the template and returns a middleware function.
app.use(toisuHandlebars(template));

http.createServer(app.requestHandler).listen(3000);
4.0.0

7 months ago

3.0.5

2 years ago

3.0.4

2 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago