koajs / ejs

a koa view render middleware, support all feature of ejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"locals" is not working

neti-soft opened this issue · comments

commented

I suppose I should be able to add global-type variables into locals and have access to them in each template, without passing them to render function. Can you confirm that, and if it is true fix that ASAP. Thanks)

example code:
ejs(app, {
root: path.join(__dirname, '/../view'),
layout: 'layout',
viewExt: 'html',
cache: true,
debug: false,
locals: {
test: "some global variable"
}
});

you can use this.state instead. I have trouble with this for long time.

Refer to ctx.state in koa.