diff --git a/lib/phlex/rails/sgml.rb b/lib/phlex/rails/sgml.rb index 48b27eb..715829b 100644 --- a/lib/phlex/rails/sgml.rb +++ b/lib/phlex/rails/sgml.rb @@ -37,13 +37,15 @@ def render(*args, **kwargs, &block) when nil partial = kwargs.delete(:partial) - if partial # this is a hack to get around https://github.com/rails/rails/issues/51015 - return raw( - @_context.view_context.render(partial, **kwargs) do |*yielded_args| - capture(*yielded_args, &block) - end, - ) - end + if partial # this is a hack to get around https://github.com/rails/rails/issues/51015 + return raw( + @_context.view_context.render(partial, **kwargs) do |*yielded_args| + capture(*yielded_args, &block) + end, + ) + else + return super + end end output = if block diff --git a/test/dummy/app/controllers/rendering_controller.rb b/test/dummy/app/controllers/rendering_controller.rb index f9482c5..d994a40 100644 --- a/test/dummy/app/controllers/rendering_controller.rb +++ b/test/dummy/app/controllers/rendering_controller.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true class RenderingController < ApplicationController + def standard_phlex + render Rendering::StandardPhlex.new + end + def partial_from_phlex render Rendering::PartialFromPhlex.new end diff --git a/test/dummy/app/views/rendering/standard_phlex.rb b/test/dummy/app/views/rendering/standard_phlex.rb new file mode 100644 index 0000000..54ed123 --- /dev/null +++ b/test/dummy/app/views/rendering/standard_phlex.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Rendering + class StandardPhlex < ApplicationView + def view_template + render Header do + h1(id: "title") { "Hello Phlex!" } + end + end + + class Header < ApplicationComponent + def view_template(&) + render(&) + end + end + end +end diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 1f0d56a..c309a65 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -19,6 +19,7 @@ get "/helpers/missing_helper", to: "helpers#missing_helper" get "/helpers/notice", to: "helpers#notice_test" + get "/rendering/standard_phlex", to: "rendering#standard_phlex" get "/rendering/partial_from_phlex", to: "rendering#partial_from_phlex" get "/rendering/view_component_from_phlex", to: "rendering#view_component_from_phlex" get "/rendering/phlex_component_from_erb", to: "rendering#phlex_component_from_erb" diff --git a/test/phlex/render_test.rb b/test/phlex/render_test.rb index bccef57..eb40476 100644 --- a/test/phlex/render_test.rb +++ b/test/phlex/render_test.rb @@ -3,6 +3,12 @@ require "test_helper" class RenderTest < ActionDispatch::IntegrationTest + test "rendering standard phlex" do + get "/rendering/standard_phlex" + assert_response :success + assert_select "h1#title", "Hello Phlex!" + end + test "rendering partial from Phlex view" do get "/rendering/partial_from_phlex" assert_response :success