Skip to content

Commit 480a16e

Browse files
authored
Add compiler awareness for &block arguments (#937)
1 parent f678cda commit 480a16e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/phlex/compiler/method_compiler.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def visit_phlex_attributes(node)
101101
end
102102

103103
def visit_phlex_block(node)
104-
if output_block?(node)
104+
if Prism::BlockArgumentNode === node
105+
[statement("__yield_content__("), node, push(")")]
106+
elsif output_block?(node)
105107
visit(node.body)
106108
elsif content_block?(node)
107109
content = node.body.body.first

quickdraw/compilation_equivalence.test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,15 @@
1414
assert_equal_html after, before
1515
end
1616
end
17+
18+
require_relative "../fixtures/page"
19+
require_relative "../fixtures/layout"
20+
21+
test "benchmark fixtures" do
22+
before = Example::Page.new.call
23+
Phlex::Compiler.compile(Example::LayoutComponent)
24+
Phlex::Compiler.compile(Example::Page)
25+
after = Example::Page.new.call
26+
27+
assert_equal_html after, before
28+
end

0 commit comments

Comments
 (0)