kyoto-framework/kyoto

It is not possible to use `render.Custom` per component

yznts opened this issue · 3 comments

yznts commented

Each render.Custom call overrides global context. With this approach it wouldn't be possible to define custom rendering on a component level.
As an option, we can store this in the state as internal, helpers.ComponentSerialize will remove it on state serialization.

I'd like to take it. Any suggestions about where to start?

yznts commented

@inthepanchine Sounds awesome! :)

Good start point for this journey is understanding how State and Context works. Both of them are instances of Store, but in case of Context it's re-used and passed in all definitions. State, otherwise, is unique for each defined component. You can see that behavior in core.Component.

So, what's general idea of render.Custom? With this functionality I would like to give developer an ability to define own custom rendering for page or component.

My current (wrong) implementation stores rendering function into the global context. We need to store that function into the core's state, with an internal: preffix. After changing that, you'll need to modify rendering handler here.

IMHO it would be a good idea also to handle this issue #85 in pair. They are related because render template function will be used to trigger render.Custom for components, like {{ render .MyComponent }}.

Temporary I don't have enough time now to give enough attention to the project, but feel free to contact me anytime! Email, Telegram, or just leave a comment here.

yznts commented

@inthepanchine sorry, friend.
Managed to finish that on weekends :)