mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 09:20:42 -07:00
Add ability to pass tags to parse_context
Co-authored-by: Dylan Thacker-Smith <[email protected]>
This commit is contained in:
co-authored by
Dylan Thacker-Smith
parent
456be2f75e
commit
3d2aa05d64
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user