Skip to content

Compatibility with the current koa2 version #19

@Sharaal

Description

@Sharaal

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions