Skip to content

Commit

Permalink
Add support for yielding arguments with capture
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed May 12, 2024
1 parent 7052ee8 commit 1fcbfd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/phlex/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,14 @@ def unsafe_raw(content = nil)
# Capture a block of output as a String.
# @note This only works if the block's receiver is the current component or the block returns a String.
# @return [String]
def capture(&block)
def capture(*args, &block)
return "" unless block

@_context.capturing_into(+"") { yield_content(&block) }
if args.length > 0
@_context.capturing_into(+"") { yield_content_with_args(*args, &block) }
else
@_context.capturing_into(+"") { yield_content(&block) }
end
end

private
Expand Down

0 comments on commit 1fcbfd3

Please sign in to comment.