mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40: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
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## 5.8.1 (unreleased)
|
## 5.8.1 (unreleased)
|
||||||
|
|
||||||
|
## 5.8.1
|
||||||
|
|
||||||
|
* Fix `{% doc %}` tag to be visitable [Guilherme Carreiro]
|
||||||
|
|
||||||
## 5.8.0
|
## 5.8.0
|
||||||
|
|
||||||
* Introduce the new `{% doc %}` tag [Guilherme Carreiro]
|
* Introduce the new `{% doc %}` tag [Guilherme Carreiro]
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ module Liquid
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nodelist
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def ensure_valid_markup(tag_name, markup, parse_context)
|
def ensure_valid_markup(tag_name, markup, parse_context)
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
VERSION = "5.8.0"
|
VERSION = "5.8.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -157,4 +157,28 @@ class DocTagUnitTest < Minitest::Test
|
|||||||
assert_template_result('', "{% doc %}123{% enddoc\nxyz %}")
|
assert_template_result('', "{% doc %}123{% enddoc\nxyz %}")
|
||||||
assert_template_result('', "{% doc %}123{% enddoc\n xyz enddoc %}")
|
assert_template_result('', "{% doc %}123{% enddoc\n xyz enddoc %}")
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user