Skip to content

Commit 6453a0e

Browse files
committedFeb 26, 2025
Implement nodelist in the Doc tag so it may be visited
1 parent a398b4c commit 6453a0e

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
 

‎History.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 5.8.1 (unreleased)
44

5+
## 5.8.1
6+
7+
* Fix `{% doc %}` tag to be visitable [Guilherme Carreiro]
8+
59
## 5.8.0
610

711
* Introduce the new `{% doc %}` tag [Guilherme Carreiro]

‎lib/liquid/tags/doc.rb

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def blank?
5555
true
5656
end
5757

58+
def nodelist
59+
[]
60+
end
61+
5862
private
5963

6064
def ensure_valid_markup(tag_name, markup, parse_context)

‎lib/liquid/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# frozen_string_literal: true
33

44
module Liquid
5-
VERSION = "5.8.0"
5+
VERSION = "5.8.1"
66
end

‎test/unit/tags/doc_tag_unit_test.rb

+24
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,28 @@ def test_doc_tag_delimiter_handling
157157
assert_template_result('', "{% doc %}123{% enddoc\nxyz %}")
158158
assert_template_result('', "{% doc %}123{% enddoc\n xyz enddoc %}")
159159
end
160+
161+
def test_doc_tag_visitor
162+
template_source = '{% doc %}{% enddoc %}'
163+
164+
assert_equal(
165+
[Liquid::Doc],
166+
visit(template_source),
167+
)
168+
end
169+
170+
private
171+
172+
def traversal(template)
173+
ParseTreeVisitor
174+
.for(Template.parse(template).root)
175+
.add_callback_for(Liquid::Doc) do |tag|
176+
tag_class = tag.class
177+
tag_class
178+
end
179+
end
180+
181+
def visit(template)
182+
traversal(template).visit.flatten.compact
183+
end
160184
end

0 commit comments

Comments
 (0)
Failed to load comments.