How can I access req object inside a render() function from fresh plugin?
Is it possible?
7 Replies
I'd get what you need from the request and put it in app state, then pass the relevant app state thru to the render
Could you add some more information like the fresh plugin so we can get a better idea of the use case?
We're using the plugin as a gateway to attach the string translations to the web page, so that it can be used by both backend and frontend code
A better i18n approach would be cool as well, haven't looked into that for a while
yes, we would like to listen popular approachs for i18n
but, in general line we are doing something like:
I think we're missing that in our API. I feel like we should change it so that the
ctx
object should match other areas of the plugin API
Filed https://github.com/denoland/fresh/issues/2220 so that we don't forget about it. (It's difficult for me to keep track of bug reports or feature requests in discord compared to github)nice! started something here: https://github.com/denoland/fresh/pull/2224
It seems there really is no convenient way of just sending out only the relevant translation strings for a given page/component/island?