Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/view_component/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading