API abstraction for use outside of Rails #472
-
Hey everyone…as the lead maintainer for the Bridgetown project, I've been looking ahead to future improvements of our rendering/template pipeline, and something I keep dreaming of is the ability to use something like ViewComponent within that framework. I'm sure there are lots of other Ruby-based projects that could benefit from the ViewComponent API. This is just a general call for discussion of ways there could perhaps be some basic abstraction of ViewComponent so that you could write a component inherited from a high-level base class that doesn't require Rails per se, and leave the Rails or non-Rails implementation to a lower level. Alternatively — though not ideal — promote an abstract class that maintains general API compatibility with ViewComponent so that a component could be retrofitted to work outside of Rails in a different framework. Perhaps that'd be a separate repo, I don't know. Anyway, I realize I'm spitballing here, but the dream 🤩 is to have a write-once-deploy-anywhere component API for the entire Ruby ecosystem of which Rails is but a part. Any thoughts along those lines is most welcome. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Thanks for starting this discussion! This is something I've had random thoughts about but haven't really looked deeply into yet. I like the idea, and I'm curious what having a decoupled "base" class would look like ( |
Beta Was this translation helpful? Give feedback.
-
Other than the content area/slotable features, the surface area of the component API doesn't seem that large. To a decent extent, components feel like POROs which become the context in which templates get executed. Probably the most complicated logic that would need to be implemented outside of Rails is identifying the appropriate template files and rendering them with the correct engine. |
Beta Was this translation helpful? Give feedback.
-
I continue to be supportive of enabling ViewComponent to be used outside of Rails, but the explicit goal of the project is to support seamless integration with Rails, and will continue to prioritize that goal. For folks looking for a solution that isn't coupled to Rails, I'd recommend https://github.com/yippee-fun/phlex. |
Beta Was this translation helpful? Give feedback.
I continue to be supportive of enabling ViewComponent to be used outside of Rails, but the explicit goal of the project is to support seamless integration with Rails, and will continue to prioritize that goal. For folks looking for a solution that isn't coupled to Rails, I'd recommend https://github.com/yippee-fun/phlex.