-
Notifications
You must be signed in to change notification settings - Fork 755
pass context to the ruby racer #298
New issue
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
Comments
Wow, that's a really cool idea! I'm hoping to enable this kind of creativity by the A renderer should implement:
Do you think this kind of feature could work with that extension API? I want clean up SprocketsRenderer a bit too, see #299 |
Yes I am great with that approach... All that the code above is doing is a little preprocessing of the incoming hash, plus it does need to get access to the underlying evaluator. If the API could present the base render function, and access to the evaluator then no PR is needed. Is that API available today? |
It's on master, but not ruby-gems Default config from the railtie: Is assigned to an attribute on SprocketsRenderer as an example: And a |
also if you get something like this together, I'd love to add a wiki page or something and link to it! There aren't any other contrib-type projects yet but I think that would be great. |
👍 Currently our approach to setting React context data on a top level component is to set some properties that are used as 'initial data' for a component that are transferred into the context object. Having this means we could forgo that convention and be able to specify the React context in much the same way we would specify properties, with the benefit of not having to mix data with properties/state. |
Okay! Probably get back to cleaning this up in a couple of weeks (I've got this working good enough for us for now) looking forward to it! |
somewhat relevant to this thread is my PR to re-implement the view helper to be request-aware. You get one instance of the helper per request. #346 (sorry, wrong button!) |
Seems like this was addressed, but I forgot to close it! |
We need to pass some ruby context to the ruby racer engine during the server side rendering process. This is a very powerful capability which allows us to access server models during pre-rendering.
I propose the following solution:
in the prerendering options allow this:
prerender: {context: {some_context: some_object, other_context: some_other_object}, static: true}
each of the context values is sent to therubyracer(v8) engine using the context key.
Of course it requires therubyracer.
I have the following code in a branch that implements this and would be happy to do a PR:
The text was updated successfully, but these errors were encountered: