Skip to content

Commit

Permalink
Remove deferred render entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Oct 3, 2024
1 parent 7f166d7 commit 5c12dfa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
1 change: 0 additions & 1 deletion lib/phlex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module Phlex
autoload :CSV, "phlex/csv"
autoload :Callable, "phlex/callable"
autoload :Context, "phlex/context"
autoload :DeferredRender, "phlex/deferred_render"
autoload :DoubleRenderError, "phlex/errors/double_render_error"
autoload :Elements, "phlex/elements"
autoload :Error, "phlex/error"
Expand Down
5 changes: 0 additions & 5 deletions lib/phlex/deferred_render.rb

This file was deleted.

28 changes: 14 additions & 14 deletions lib/phlex/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,23 @@ def call(buffer = +"", context: Phlex::Context.new, view_context: nil, parent: n
end

@_context.around_render do
before_template(&block)

around_template do
if block
if Phlex::DeferredRender === self
vanish(self, &block)
view_template
else
view_template do |*args|
if args.length > 0
__yield_content_with_args__(*args, &block)
else
__yield_content__(&block)
end
view_template do |*args|
if args.length > 0
__yield_content_with_args__(*args, &block)
else
__yield_content__(&block)
end
end
else
view_template
end
end

after_template
end

unless parent
Expand Down Expand Up @@ -235,7 +234,11 @@ def render(renderable = nil, &)
def vanish(*args)
return unless block_given?

@_context.capturing_into(Phlex::BlackHole) { yield(*args) }
if args.length > 0
@_context.capturing_into(Phlex::BlackHole) { yield(*args) }
else
@_context.capturing_into(Phlex::BlackHole) { yield(self) }
end

nil
end
Expand All @@ -252,10 +255,7 @@ def format_object(object)
end

def around_template
before_template
yield
after_template

nil
end

Expand Down
14 changes: 7 additions & 7 deletions quickdraw/sgml/callbacks.test.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# frozen_string_literal: true

class Example < Phlex::HTML
def around_template
def before_template
i { "1" }
end

def around_template
i { "2" }

super do
i { "3" }
yield
i { "5" }
end

i { "7" }
end

def before_template
i { "2" }
i { "6" }
end

def after_template
i { "6" }
i { "7" }
end

def view_template
Expand Down

0 comments on commit 5c12dfa

Please sign in to comment.