We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
should I set it in all render function?
render
likes global locals
ctx.render('sign/signin', { session: ctx.session, flash: ctx.flash })
The text was updated successfully, but these errors were encountered:
I got it ! #1 add a middleware
app.use(async (ctx, next) => { const oldRender = ctx.render const user = ctx.session.user || null const flash = ctx.session.flash ctx.render = async (tpl, locals, options, noCache) => { const data = _.merge({ user, flash }, locals) console.log(data) await oldRender.call(ctx, tpl, data, options, noCache) } await next() })
Sorry, something went wrong.
You don't need to create a new ctx.render, use ctx.state instead:
ctx.render
ctx.state
app.use((ctx, next) => { ... ctx.state.session = ctx.session ... }) app.use((ctx) => { ctx.render('tpl') // session will be available in view automatically })
thanks much!
No branches or pull requests
should I set it in all
render
function?likes global locals
The text was updated successfully, but these errors were encountered: