View replacement for Express using Template.
Install with npm:
npm i express-template --save-dev
npm test
// 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);
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 nameroot
root path for view lookup
options
{Object}fn
{Function}
Render with the given options
and callback fn(err, str)
.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Brian Woodward
Copyright (c) 2015 Brian Woodward
Released under the MIT license
This file was generated by verb on January 14, 2015.