Skip to content

koa middleware allowing the use of usematch templates

Notifications You must be signed in to change notification settings

cmroanirgo/koa-usematch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

koa-usematch

This provides middleware for koa to use the usematch templating engine.

Installation

In your existing koa folder:

npm install koa-usematch

Usage

var options = {
	views: path.join(__dirname, 'views'),
	partials: path.join(__dirname, 'partials'),
	defaults: { ... default fields here ...}
}
var render = require('koa-usematch')( options );

router.get('/', function *(next) {
	var data = { title: "Home", ... }
	this.body = yield render('home', data);
});

Where options can contain any usematch option, including:

var defaultSettings = {
	cache: true,					// whether views and partials are cached. For a server this should probably be enabled
	viewExt: 'html',				// views and partials all end with this extension
	views: '/path/to/views',		// the path to the 'views' folder for an MVC style implementation
	partials: '/path/to/partials'	// the path to any 'partials' (also uses viewExt setting)
};

About

koa middleware allowing the use of usematch templates

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published