diff --git a/lib/view_component/compiler.rb b/lib/view_component/compiler.rb index c4ab88df4..212b61da3 100644 --- a/lib/view_component/compiler.rb +++ b/lib/view_component/compiler.rb @@ -78,7 +78,7 @@ def define_render_template_for "variant&.to_sym == #{template.variant.inspect}" else [ - template.default_format? ? "(format == #{ViewComponent::Base::VC_INTERNAL_DEFAULT_FORMAT.inspect} || format.nil?)" : "format == #{template.format.inspect}", + template.default_format? ? "(format == #{ViewComponent::Base::VC_INTERNAL_DEFAULT_FORMAT.inspect} || format == :turbo_stream || format.nil?)" : "format == #{template.format.inspect}", template.variant.nil? ? "variant.nil?" : "variant&.to_sym == #{template.variant.inspect}" ].join(" && ") end @@ -95,6 +95,7 @@ def define_render_template_for @component.silence_redefinition_of_method(:render_template_for) @component.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def render_template_for(variant = nil, format = nil) + Rails.logger.info("Rendering template for variant: \#{variant}, format: \#{format}") #{method_body} end RUBY diff --git a/lib/view_component/template.rb b/lib/view_component/template.rb index f01fd9368..1e9816844 100644 --- a/lib/view_component/template.rb +++ b/lib/view_component/template.rb @@ -80,7 +80,7 @@ def inline? end def default_format? - @this_format == ViewComponent::Base::VC_INTERNAL_DEFAULT_FORMAT + @this_format == ViewComponent::Base::VC_INTERNAL_DEFAULT_FORMAT || @this_format == :turbo_stream end def format