Question: global variable in view file
raphaelsoul opened this issue · 2 comments
raphaelsoul commented
How can I access ctx
in a view file?
For example, I want to visit ctx.state.user
in a .hbs
file.
is there some way globally passing some value? Thanks
int64ago commented
What do you mean global variable
? Does await ctx.render('user.hbs', { user: ctx.state.user })
work for you?
raphaelsoul commented
my bad. I use passport
to authenticate my visitors. And I found I can use {{ user }}
to access my ctx.state.user
.