mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Implement nodelist in the Doc tag so it may be visited
This commit is contained in:
committed by
Guilherme Carreiro
parent
a398b4cc74
commit
6453a0ea48
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user