Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with the current koa2 version #19

Open
Sharaal opened this issue Apr 26, 2016 · 2 comments
Open

Compatibility with the current koa2 version #19

Sharaal opened this issue Apr 26, 2016 · 2 comments

Comments

@Sharaal
Copy link

Sharaal commented Apr 26, 2016

Hi,

currently the module use the outdated syntax with function*, yield and this.body.

To use the module with the current koa2 version the render function must be co-wrapped, the writeBody set to false and ctx.body manually set:

import co from 'co';
import Koa from 'koa';
import render from 'koa-swig';

const app = new Koa();
app.context.render = co.wrap(render({ writeBody: false }));
app.use(async (ctx) => {
  ctx.body = await ctx.render('index.html.twig');
});
app.listen(process.env.PORT);
@microacup
Copy link

You are right!

@darethas
Copy link

darethas commented Mar 2, 2017

This worked for me, except with writeBody: true.

writeBody: false would not render the template with locals.

using koa-swig 2.2.1, and koa 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants