An open API service indexing awesome lists of open source software.

https://github.com/cmroanirgo/koa-usematch

koa middleware allowing the use of usematch templates
https://github.com/cmroanirgo/koa-usematch

koa-middleware koa-usematch template-engine

Last synced: 3 months ago
JSON representation

koa middleware allowing the use of usematch templates

Awesome Lists containing this project

README

        

# koa-usematch

This provides middleware for koa to use the [usematch templating engine](https://www.npmjs.com/package/usematch).

## 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](https://github.com/cmroanirgo/usematch#usematch-api), 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)
};
```