Skip to content

gtomitsuka/simple-handlebars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-handlebars

Build Status

npm install simple-handlebars

simple-handlebars is a Handlebars engine designed for simplicity, made for express. It supports partials, multiple extensions(like .hbs and .handlebars) and view caching for a maximum performance.

How to Use

var app = require('express')();
var hbs = require('simple-handlebars');

app.engine('hbs', hbs({
  partials: __dirname + '/views/partials',
  extension: '.hbs'
}));

app.set('views', __dirname + '/views');

API

hbs(options)

options:

partials - an array or a string. If it is a string, reads it as a directory and

extension - the file extension you're using. Usually .hbs or .handlebars. By default uses .hbs. This property is ignored if you send an array to partials

handlebars - if you need a different Handlebars implementation. By default uses handlebars

caches - By default, simple-handlebars only caches if process.env.NODE_ENV is 'production'.

hbs#registerHelper(name, fnc)

Calls InternalHandlebars.registerHelper(name, fnc).

var app = require('express')();
var hbs = require('simple-handlebars');

var instance = hbs({
  partials: __dirname + '/views/partials',
  extension: '.hbs'
});

instance.registerHelper('helper', function() {
  // your helper here
});

app.engine('hbs', instance);

app.set('views', __dirname + '/views');

About

Simple but complete Handlebars engine for Express

Resources

License

Stars

Watchers

Forks

Packages

No packages published