koa-artTemplate
Advanced tools
Comparing version 1.0.2 to 2.0.0
@@ -12,6 +12,7 @@ const template = require('art-template') | ||
template.config('extname', ext || '.html') | ||
return function *(next) { | ||
this.render = render | ||
yield next | ||
return function (ctx, next) { | ||
if (ctx.render) return next() | ||
ctx.render = render | ||
next() | ||
} | ||
} |
{ | ||
"name": "koa-artTemplate", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "koa artTemplate middleware", | ||
@@ -8,3 +8,4 @@ "main": "index.js", | ||
"test": "nyc ava", | ||
"cover": "nyc report --reporter=lcov" | ||
"cover": "nyc report --reporter=lcov", | ||
"publish": "npm publish --tag=next" | ||
}, | ||
@@ -28,3 +29,3 @@ "repository": { | ||
"babel-register": "^6.11.6", | ||
"koa": "^1.2.1", | ||
"koa": "^2.0.0-alpha.5", | ||
"nyc": "^8.1.0", | ||
@@ -31,0 +32,0 @@ "supertest": "^2.0.0", |
@@ -16,6 +16,6 @@ import test from 'ava' | ||
app.use(koaArt('./../views/')) | ||
app.use(function *() { | ||
t.truthy(this.render) | ||
t.true(this.render instanceof Function) | ||
this.body = 'hello' | ||
app.use((ctx, next) => { | ||
t.truthy(ctx.render) | ||
t.true(ctx.render instanceof Function) | ||
ctx.body = 'hello' | ||
}) | ||
@@ -29,4 +29,4 @@ const res = await supertest(app.listen()).get('/').expect(200) | ||
app.use(koaArt('../views/')) | ||
app.use(function *(next) { | ||
this.body = this.render('index', {}) | ||
app.use((ctx, next) => { | ||
ctx.body = ctx.render('index', {}) | ||
}) | ||
@@ -40,4 +40,4 @@ const res = await supertest(app.listen()).get('/').expect(200) | ||
app.use(koaArt('../views/')) | ||
app.use(function *(next) { | ||
this.body = this.render('template', { test: true }) | ||
app.use((ctx, next) => { | ||
ctx.body = ctx.render('template', { test: true }) | ||
}) | ||
@@ -51,4 +51,4 @@ const res = await supertest(app.listen()).get('/').expect(200) | ||
app.use(koaArt('../views/')) | ||
app.use(function *(next) { | ||
this.body = this.render('template', { test: true }) | ||
app.use((ctx, next) => { | ||
ctx.body = ctx.render('template', { test: true }) | ||
}) | ||
@@ -62,4 +62,4 @@ const res = await supertest(app.listen()).get('/').expect(200) | ||
app.use(koaArt('../views/')) | ||
app.use(function *(next) { | ||
this.body = this.render('partial/header', { title: 'This is Header' }) | ||
app.use((ctx, next) => { | ||
ctx.body = ctx.render('partial/header', { title: 'This is Header' }) | ||
}) | ||
@@ -73,4 +73,4 @@ const res = await supertest(app.listen()).get('/').expect(200) | ||
app.use(koaArt('../views/')) | ||
app.use(function *(next) { | ||
this.body = this.render('partial_test', { title: 'This is Header' }) | ||
app.use((ctx, next) => { | ||
ctx.body = ctx.render('partial_test', { title: 'This is Header' }) | ||
}) | ||
@@ -77,0 +77,0 @@ const res = await supertest(app.listen()).get('/').expect(200) |
17598
81