1.0.0 • Published 8 years ago

bluegate-handlebars v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

BlueGate Handlebars

Build Status Coverage Status Dependency Status Known Vulnerabilities

Render responses with Handlebars templates in a BlueGate application.

Installation

Install using npm install bluegate-handlebars

Quick example

Save templates in /templates folder with a .hbs extension.

var BlueGate = require('bluegate');
var app = new BlueGate();
app.listen(8080);

require('bluegate-handlebars')(app);

app.process('GET /', function() {
  this.setParameter('template', 'homepage');
  return {title: 'Test'};
});

Template in /templates/homepage.hbs:

<h1>{{title}}</h1>

The template name used in the parameter is the filename of the template, without extension.

Custom options

A files option can be provided to indicate where the template files can be found. This pattern is parsed by the globby module.

require('bluegate-handlebars')(app, {
  files: 'templates/**/*.hbs'
});