Comments (7)
@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.
@DanielDahan Can you, please explain how did you managed to solve this issue?
from koa-pug.
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.
Can we reopen this until there is a fix that doesn't require removing yield statements? They're kind of important
from koa-pug.
I looked over my code, and I also removed the yield call.
from koa-pug.
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.
@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)
- hot to get koa's "this" inside view? HOT 4
- 'pretty: true' not working HOT 3
- koa-pug HOT 2
- this.render is not a function HOT 5
- Is there an other way to transform the session and flash ? HOT 3
- Outdated dependencies HOT 3
- Can you write a pug view for egg? HOT 4
- Can Koa-pug render multiple blocks? HOT 3
- TypeScript error on koa import HOT 2
- jade extends basedir functionality not working with absolute paths HOT 1
- Why does `BaseContext.render` have to return `void` ? HOT 1
- Exposing locals to layout HOT 4
- Map is not defined HOT 4
- If the view provided is a folder, pick index.jade as default HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-pug.