Add ability to pass tags to parse_context

Co-authored-by: Dylan Thacker-Smith <[email protected]>
This commit is contained in:
Matt Rose
2022-09-29 11:35:46 -04:00
co-authored by Dylan Thacker-Smith
parent 456be2f75e
commit 3d2aa05d64
5 changed files with 37 additions and 8 deletions
+29
View File
@@ -42,4 +42,33 @@ class TagTest < Minitest::Test
assert_equal(buf.object_id, output.object_id)
end
end
def test_tags_can_be_overwritten_using_parse_context
tag_name = 'testtag'
original_tag = Class.new(Block) do
def render(*)
'original_tag'
end
end
new_tag = Class.new(Block) do
def render(*)
'new_tag'
end
end
tags_overwrite = Liquid::Template::TagRegistry.new
tags_overwrite[tag_name] = new_tag
with_custom_tag(tag_name, original_tag) do
liquid = "{% #{tag_name} %} {% end#{tag_name} %}"
template = Liquid::Template.parse(liquid)
assert_equal('original_tag', template.render)
template_with_overwrite = Liquid::Template.parse(liquid, tags: tags_overwrite)
assert_equal('new_tag', template_with_overwrite.render)
end
end
end