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
- Host: GitHub
- URL: https://github.com/cmroanirgo/koa-usematch
- Owner: cmroanirgo
- Created: 2017-02-26T00:01:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T00:39:47.000Z (over 8 years ago)
- Last Synced: 2025-03-21T08:46:29.243Z (3 months ago)
- Topics: koa-middleware, koa-usematch, template-engine
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
};
```