Skip to content

Commit

Permalink
Update sgml.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Sep 24, 2024
1 parent f3b7093 commit 062bbe8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/phlex/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def to_proc
proc { |c| c.render(self) }
end

def yielder
yield(self)
end

def call(buffer = +"", context: Phlex::Context.new, view_context: nil, parent: nil, fragments: nil, &block)
@_buffer = buffer
@_context = context
Expand All @@ -89,9 +93,9 @@ def call(buffer = +"", context: Phlex::Context.new, view_context: nil, parent: n
@_context.around_render do
around_template do
if block
view_template do |*args|
content = (args.length == 0) ? capture(self, &block) : capture(*args, &block)
content = capture(self) { yielder(&block) }

view_template do
context = @_context
next if context.fragments && !context.in_target_fragment

Expand Down
6 changes: 4 additions & 2 deletions quickdraw/sgml/capture.test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

class ExampleCaptureWithArguments < Phlex::HTML
def view_template(&block)
h1 { capture("a", "b", "c", &block) }
def yielder = yield("a", "b", "c")

def view_template(...)
h1(...)
end
end

Expand Down

0 comments on commit 062bbe8

Please sign in to comment.