Skip to content
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

Add documentation for component support #38656

Merged
merged 7 commits into from
Mar 13, 2020
Merged

Add documentation for component support #38656

merged 7 commits into from
Mar 13, 2020

Conversation

joelhawksley
Copy link
Contributor

Summary

This PR adds some basic documentation around the support for 3rd-party component libraries introduced in #36388 and #37919.

It also includes some minor cleanups of the example components in the test suite.

@@ -37,5 +37,5 @@ def self.compile
end

private
attr_reader :title, :view_context
attr_reader :view_context
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we include this weighty thing in here even? Could we replace with something closer to Class.new { def render_in(view_context); "hey"; end }?

@@ -277,6 +277,16 @@ since an attacker could use this action to access security sensitive files in yo

TIP: `send_file` is often a faster and better option if a layout isn't required.

#### Rendering view components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly don't think this is an apt description. The support is for any object that responds to render_in, the fact that someone can implement components based on that is a side effect.

@@ -82,8 +82,9 @@ def initialize(controller, env, defaults)
# need to call <tt>.to_json</tt> on the object you want to render.
# * <tt>:body</tt> - Renders provided text and sets content type of <tt>text/plain</tt>.
#
# If no <tt>options</tt> hash is passed or if <tt>:update</tt> is specified, the default is
# to render a partial and use the second parameter as the locals hash.
# <tt>options</tt> hash is passed or if <tt>:update</tt> is specified, the default is to either call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like If no got lost. Think the wording is slightly clunky too. I think there's a version that we can write in half the length.

@joelhawksley
Copy link
Contributor Author

@kaspth this should be ready for another review. I couldn't get the copy to be half the length, but I feel like it's more clear 🙇

@joelhawksley joelhawksley requested a review from kaspth March 5, 2020 22:23
@kaspth kaspth merged commit c82a919 into rails:master Mar 13, 2020
@kaspth
Copy link
Contributor

kaspth commented Mar 13, 2020

Sweet 🙌

@joelhawksley joelhawksley deleted the component-cleanups branch March 13, 2020 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants