-
Notifications
You must be signed in to change notification settings - Fork 428
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
Render behavior in component classes #569
Comments
@dvisockas thank you for filing this issue! The original implementation of ViewComponent actually used almost this exact syntax! We moved to using separate templates for a couple of reasons, including:
That being said, I'd love to find a way to go beyond our support for Inline Components. I think that in a lot of cases, having a single file for a component instead of two makes for a cleaner, simpler design. |
It would be possible to write the view part using rails tag helpers, but that would be cruel. |
This comment has been minimized.
This comment has been minimized.
@dvisockas besides those I already mentioned, perhaps @soutaro can elaborate the concerns re: Ruby 3 typing? |
Closed by #1556 |
Feature request
Would it make sense to have template code in the component class definition file (similar to how JSX works)?
I just thought that it would be cool to have something like a
render
method that could hold the template code in the class, not a separate file. Something like:Motivation
React uses this in JSX. Also this would reduce total component file count by 2. However if someone would like to render js, css, etc. this would need methods like
render_js
or something (?) (or wouldn't make sense anymore)Another drawback is the slim/haml indentation, as they would have to be aligned with the left most column of the file, since squiggly heredoc strips whitespace from each line of the string.
The text was updated successfully, but these errors were encountered: