Skip to content

Commit 8c2f36a

Browse files
authored
Fix render with trailing comment (#86)
Resolves #80
1 parent f5be4d8 commit 8c2f36a

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/reactionview/template/handlers/herb/herb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def add_expression(indicator, code)
5656
if expression_block?
5757
@src << " " << code
5858
else
59-
@src << "(" << code << ")"
59+
@src << "(" << code << trailing_newline(code) << ")"
6060
end
6161
end
6262
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@output_buffer.append=(render(component) # rubocop:disable Some/Rule
2+
);
3+
@output_buffer

test/template/handlers/herb_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,10 @@ def @view_context.ui_badge(count, **_options)
359359
assert_compiled_snapshot(template)
360360
assert_evaluated_snapshot(template)
361361
end
362+
363+
test "inline comment on expression compiles to valid Ruby" do
364+
template = %(<%= render(component) # rubocop:disable Some/Rule %>)
365+
366+
assert_compiled_snapshot(template)
367+
end
362368
end

0 commit comments

Comments
 (0)