Skip to content
/ exphbs Public
forked from gnowoel/exphbs

A Handlebars view engine for Express

Notifications You must be signed in to change notification settings

anestin/exphbs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exphbs Build Status

A Handlebars view engine for Express.

Node.js 9.5.0 Node.js 8.9.4 Node.js 7.10.1 Node.js 6.12.3 Node.js 5.12.0
Express 4
Express 3

Features

Layouts:

  • Declaring layout with a render option or template comment ({{!< layout}})
  • Nested layouts with arbitrary depth

Partials:

  • Autoloading from defined directory (defaults to views/partials)
  • Namespaced partial names (based on relative paths)
  • Supports any file extension (defaults to hbs and html)
  • Dynamically applying changes during development

Helpers:

  • Autoloading from defined directory (defaults to views/helpers)

Block inheritance:

  • Defining named blocks in layouts then extend them in templates

Variables:

  • Defining @variables that can be accessed from any context in a template

Precompiling:

  • Templates and partials are precompiled and cached in production

Instances:

  • Creating a new instance of separate cache
  • Instantiating with user-provided Handlebars object

Getting started

Installation:

$ npm install exphbs

Registering view engine:

app.engine('hbs', require('exphbs'));
app.set('view engine', 'hbs');

Default directory structure:

.
├── app.js
└─┬ views/
  ├── index.hbs
  ├── helpers/
  ├── layouts/
  └── partials/

Example

Check out example directory for a complete example. You can play around with it on Runnable.

Docs

Tests

$ npm install
$ npm test

License

MIT

About

A Handlebars view engine for Express

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 96.5%
  • HTML 3.5%