From 7baa0ccb4f07c105761a450e70c71db6f71aa9e9 Mon Sep 17 00:00:00 2001 From: stephann <3025661+stephannv@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:01:37 -0300 Subject: [PATCH] Reimplement the DeferredRender module (#13) --- Gemfile | 1 + lib/phlex/slotable.rb | 9 ++++++++- phlex-slotable.gemspec | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index d91bfb6..8379e01 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,5 @@ gemspec gem "benchmark-ips", "2.14.0" gem "minitest", "5.22.3" gem "rake", "13.2.1" +gem "phlex", github: "phlex-ruby/phlex" gem "standard", "1.35.1" diff --git a/lib/phlex/slotable.rb b/lib/phlex/slotable.rb index aff29ee..5fe9a3f 100644 --- a/lib/phlex/slotable.rb +++ b/lib/phlex/slotable.rb @@ -5,13 +5,20 @@ module Phlex module Slotable + module DeferredRender + def before_template(&) + vanish(&) + super + end + end + def self.included(base) base.extend(ClassMethods) end module ClassMethods def slot(slot_name, callable = nil, types: nil, collection: false) - include Phlex::DeferredRender + include DeferredRender if types types.each do |type, callable| diff --git a/phlex-slotable.gemspec b/phlex-slotable.gemspec index ffa9a29..387406e 100644 --- a/phlex-slotable.gemspec +++ b/phlex-slotable.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] # Uncomment to register a new dependency of your gem - spec.add_dependency "phlex", ">= 1.9", "< 3" + # spec.add_dependency "phlex", ">= 1.9", "< 3" # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html