Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/herb/engine/visitors/debug_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def visit_erb_content_node(node)
if !@in_attribute && !@in_html_comment && !@in_html_doctype && !in_excluded_context? && erb_output?(node.tag_opening.value)
code = node.content.value.strip

@erb_nodes_to_wrap << node unless complex_rails_helper?(code)
@erb_nodes_to_wrap << node unless complex_rails_helper?(code) || include_debug_disable_comment?(code)
end

super
Expand Down
21 changes: 21 additions & 0 deletions test/engine/debug_mode_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,27 @@ def inspect
assert_snapshot_matches(compiled, "debug_mode_test-0")
end

test "output tag with debug disable comment does NOT get debug span" do
template = %(<%= tag.td "Ada", id: "cell_1" # herb:debug disable %>)

assert_compiled_snapshot(template, visitors: [Herb::Engine::DebugVisitor.new], filename: "app/views/people/_cell.html.erb")
end

test "output tag with debug disable comment leaves the other output tags wrapped" do
template = <<~ERB
<%= tag.tr tag.td(@name), id: "row_1" # herb:debug disable %>
<p><%= @name %></p>
ERB

assert_compiled_snapshot(template, visitors: [Herb::Engine::DebugVisitor.new], filename: "app/views/people/_row.html.erb")
end

test "output tag with debug disable comment and extra whitespace" do
template = %(<%= tag.td "Ada" # herb:debug disable %>)

assert_compiled_snapshot(template, visitors: [Herb::Engine::DebugVisitor.new])
end

describe "marking which render a tag came from" do
def visitors_for(node:, instrument: true)
visitors = [Herb::Engine::DebugVisitor.new(node: node)]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading