2.2.0 • Published 5 years ago

toisu-handlebars v2.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

toisu-handlebars

Greenkeeper badge

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

install

To install toisu-handlebars into your project, use:

npm install --save toisu-handlebars

usage

const http = require('http');
const Toisu = require('toisu');
const toisuHandlebars = require('toisu-handlebars');
const dbModule = require('./a-bd-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);
2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.0.1

9 years ago