Implement nodelist in the Doc tag so it may be visited

This commit is contained in:
Guilherme Carreiro
2025-02-26 13:14:39 +01:00
committed by Guilherme Carreiro
parent a398b4cc74
commit 6453a0ea48
4 changed files with 33 additions and 1 deletions
+24
View File
@@ -157,4 +157,28 @@ class DocTagUnitTest < Minitest::Test
assert_template_result('', "{% doc %}123{% enddoc\nxyz %}")
assert_template_result('', "{% doc %}123{% enddoc\n xyz enddoc %}")
end
def test_doc_tag_visitor
template_source = '{% doc %}{% enddoc %}'
assert_equal(
[Liquid::Doc],
visit(template_source),
)
end
private
def traversal(template)
ParseTreeVisitor
.for(Template.parse(template).root)
.add_callback_for(Liquid::Doc) do |tag|
tag_class = tag.class
tag_class
end
end
def visit(template)
traversal(template).visit.flatten.compact
end
end