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 template information to multiple template error messages. #2115

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

joelhawksley
Copy link
Member

In service of helping debug #2114, this change fleshes out the template error messages to include the current list of templates.

In service of helping debug #2114,
this change fleshes out the template error messages to include
the current list of templates.
if templates
message << "\n"
message << "Templates:"
message << templates.map(&:inspect).join("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want inspect output, or just the template name?

Copy link
Member Author

Choose a reason for hiding this comment

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

All of the inspect output, as it shows what type of templates there are for the component and where they are defined:

Template file and inline render method found for variant 'phone' in VariantTemplateAndInlineVariantTemplateComponent. There can only be a template file or inline render method per variant.

Templates:

#<ViewComponent::Template:0x000000012a9980d8 @component=VariantTemplateAndInlineVariantTemplateComponent, @type=:file, @this_format=:html, @variant=:phone, @lineno=0, @path=\"/Users/joelhawksley/github/view_component/test/sandbox/app/components/variant_template_and_inline_variant_template_component.html+phone.erb\", @extension=\"erb\", @source=nil, @method_name=nil, @defined_on_self=true, @source_originally_nil=true, @call_method_name=\"call_phone\">

#<ViewComponent::Template:0x000000012a997ef8 @component=VariantTemplateAndInlineVariantTemplateComponent, @type=:inline_call, @this_format=:html, @variant=:phone, @lineno=nil, @path=nil, @extension=nil, @source=nil, @method_name=:call_phone, @defined_on_self=true, @source_originally_nil=true, @call_method_name=:call_phone>

@joelhawksley joelhawksley merged commit f87c87b into main Oct 1, 2024
19 checks passed
@joelhawksley joelhawksley deleted the multi-template-error branch October 1, 2024 17:05
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.

3 participants