X Tutup
The Wayback Machine - https://web.archive.org/web/20220707065753/https://github.com/github/view_component/pull/1070
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 test component for multiple formats support #1070

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vpereira
Copy link

@vpereira vpereira commented Sep 13, 2021

As asked by @joelhawksley on issue #1062, I'm opening a PR with a test component with multiple formats (html and text)

Feel free to guide me if something is missing.

@vpereira vpereira requested a review from as a code owner Sep 13, 2021
@vpereira vpereira force-pushed the multiple_formats_support branch from 2cad89f to 3c2e90a Compare Sep 13, 2021
@vpereira vpereira force-pushed the multiple_formats_support branch from 3c2e90a to cede0da Compare Sep 13, 2021
Copy link
Contributor

@joelhawksley joelhawksley left a comment

Thanks for adding this test case! We should pair on making it pass 😄

Email me: joelhawksley@github.com

docs/CHANGELOG.md Outdated Show resolved Hide resolved

class ViewComponentMultipleFormatsTest < ViewComponent::TestCase
def test_render_html
render_inline(MyComponentMultipleFormat.new, format: :html)
Copy link
Contributor

@joelhawksley joelhawksley Sep 13, 2021

Choose a reason for hiding this comment

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

Wouldn't the format be set by the request? I'm guessing we'd need to add a with_request_format test helper.

Copy link
Author

@vpereira vpereira Sep 14, 2021

Choose a reason for hiding this comment

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

Ok, I started with a skeleton code/pseudo code.

What I'm thinking to do is:

  • check if there is a view for #{component}.#{format}.#{extension}. if it exists, set it as view.

Co-authored-by: Joel Hawksley <joelhawksley@github.com>
@vpereira vpereira force-pushed the multiple_formats_support branch from 1e58d68 to 5487678 Compare Sep 14, 2021
@vpereira vpereira force-pushed the multiple_formats_support branch from f6aa825 to c5a1f3d Compare Sep 14, 2021
@vpereira
Copy link
Author

@vpereira vpereira commented Sep 14, 2021

@joelhawksley any reason why view_component isn't using https://github.com/rails/rails/blob/main/actionview/lib/action_view/lookup_context.rb to find the templates?

@joelhawksley
Copy link
Contributor

@joelhawksley joelhawksley commented Sep 14, 2021

@vpereira we are not using the ActionView context as we want to keep ViewComponent templates separate from ActionView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants
X Tutup