express-template

0.3.0 • Public • Published

express-template NPM version

View replacement for Express using Template.

Install

Install with npm:

npm i express-template --save-dev

Run tests

npm test

Usage

// create normal express app
var express = require('express');
var app = express();
 
// create an instance of Template to use
var Template = require('template');
var template = new Template();
 
// require in express-template
var View = require('express-template')(template);
// add some global configuration
View.config({
  data: ['data/*.json'],
  layouts: ['views/layouts/*.hbs'],
  partials: ['views/{partials, includes}/*.hbs']
});
 
// configure the express app so it uses View
app.set('view', View);

API

View

Initialize a new View with the given name. This View class matches the interface for the View class in express so it can replace the default View engine.

  • name {String}
  • options {Object}

Options:

  • defaultEngine the default template engine name
  • root root path for view lookup

.render

  • options {Object}
  • fn {Function}

Render with the given options and callback fn(err, str).

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright (c) 2015 Brian Woodward
Released under the MIT license


This file was generated by verb on January 14, 2015.

Package Sidebar

Install

npm i express-template

Weekly Downloads

1

Version

0.3.0

License

none

Last publish

Collaborators

  • doowb