From 5f188f3a79a533d6f0698d6b2f45517f8da7c5fc Mon Sep 17 00:00:00 2001 From: stephann <3025661+stephannv@users.noreply.github.com> Date: Sat, 21 Dec 2024 09:03:58 -0300 Subject: [PATCH] Allow rendering nil --- lib/phlex/rails/sgml.rb | 2 ++ test/dummy/app/views/rendering/standard_phlex.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/phlex/rails/sgml.rb b/lib/phlex/rails/sgml.rb index 71f6f5a..9fcad14 100644 --- a/lib/phlex/rails/sgml.rb +++ b/lib/phlex/rails/sgml.rb @@ -42,6 +42,8 @@ def render(*args, **kwargs, &block) return super if renderable < Phlex::SGML when Enumerable return super unless ActiveRecord::Relation === renderable + when nil + return super if kwargs.length == 0 end return super if args.length == 0 && kwargs.length == 0 diff --git a/test/dummy/app/views/rendering/standard_phlex.rb b/test/dummy/app/views/rendering/standard_phlex.rb index 54ed123..70984f1 100644 --- a/test/dummy/app/views/rendering/standard_phlex.rb +++ b/test/dummy/app/views/rendering/standard_phlex.rb @@ -3,6 +3,8 @@ module Rendering class StandardPhlex < ApplicationView def view_template + render nil + render Header do h1(id: "title") { "Hello Phlex!" } end