From 1fcbfd360d7bd19dcaf0118d52e156b6e09df4c6 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Sun, 12 May 2024 18:02:33 +0100 Subject: [PATCH] Add support for yielding arguments with capture --- lib/phlex/sgml.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb index 215255a9..7757c450 100644 --- a/lib/phlex/sgml.rb +++ b/lib/phlex/sgml.rb @@ -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