Giter Club home page Giter Club logo

Comments (7)

chrisyip avatar chrisyip commented on June 28, 2024 1

@ladytellur koa-pug supports koa@1 and koa@2, just use this.render() without yield:

const app = new Koa
const pug = new Pug({ /* options */ })
pug.use(app)

app.use(function* () {
  this.render('index')
})

from koa-pug.

qw3r avatar qw3r commented on June 28, 2024

@DanielDahan Can you, please explain how did you managed to solve this issue?

from koa-pug.

albertogasparin avatar albertogasparin commented on June 28, 2024

I've solved it by removing yeld:

router.get('/', function *() {
  this.render('index', { a: b });
});

However it might not be the behaviour you want.

from koa-pug.

watzon avatar watzon commented on June 28, 2024

Can we reopen this until there is a fix that doesn't require removing yield statements? They're kind of important

from koa-pug.

daniel-jonathan avatar daniel-jonathan commented on June 28, 2024

I looked over my code, and I also removed the yield call.

from koa-pug.

chrisyip avatar chrisyip commented on June 28, 2024

this.render doesn't require yield statement, it just a normal function.

Here's the reasons:

Normal function is faster than generator function:
iojs 1.6.4
Normal function x 163,231 ops/sec ±1.33% (180 runs sampled)
Generator function x 74,904 ops/sec ±1.86% (173 runs sampled)
Koa team encourages to use normal functions (see v2):
app.use(ctx => {
  ctx.body = 'Hello World';
})

I'll update the doc.

from koa-pug.

ladytellur avatar ladytellur commented on June 28, 2024

@chrisyip some of us just wants to use koa@1 until async/await will become native in stable Node version

from koa-pug.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.