mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 07:05:12 -07:00
Fixed tests and include tag code to use register's file_system
This commit is contained in:
@@ -73,7 +73,7 @@ module Liquid
|
|||||||
if cached = cached_partials[template_name]
|
if cached = cached_partials[template_name]
|
||||||
cached
|
cached
|
||||||
else
|
else
|
||||||
if @partial && context.registers[:file_system].nil?
|
if @partial
|
||||||
partial = @partial
|
partial = @partial
|
||||||
else
|
else
|
||||||
partial = Liquid::Template.parse(read_template_from_file_system(context), pass_options)
|
partial = Liquid::Template.parse(read_template_from_file_system(context), pass_options)
|
||||||
@@ -85,7 +85,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def read_template_from_file_system(context)
|
def read_template_from_file_system(context)
|
||||||
file_system = context.registers[:file_system] || parsed_file_system || Liquid::Template.file_system
|
file_system = context.registers[:file_system] || Liquid::Template.file_system
|
||||||
|
|
||||||
file_system.read_template_file(context[@template_name])
|
file_system.read_template_file(context[@template_name])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -86,17 +86,12 @@ class IncludeTagTest < Minitest::Test
|
|||||||
|
|
||||||
def test_include_tag_can_use_file_system_at_parse_so_it_can_be_parsed_before_rendered
|
def test_include_tag_can_use_file_system_at_parse_so_it_can_be_parsed_before_rendered
|
||||||
assert_equal 'from ParseFileSystem',
|
assert_equal 'from ParseFileSystem',
|
||||||
Template.parse("{% include 'pick_a_source' %}",file_system: ParseFileSystem.new).render!({})
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_include_tag_looks_at_file_system_passed_in_registers_over_parse_options
|
|
||||||
assert_equal 'from OtherFileSystem',
|
|
||||||
Template.parse("{% include 'pick_a_source' %}",file_system: ParseFileSystem.new).render!({}, :registers => {:file_system => OtherFileSystem.new})
|
Template.parse("{% include 'pick_a_source' %}",file_system: ParseFileSystem.new).render!({}, :registers => {:file_system => OtherFileSystem.new})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_include_tag_use_parse_option_file_system_even_if_partial_can_be_preparsed
|
def test_include_tag_use_registers_file_system_when_it_cant_be_preparse
|
||||||
assert_equal 'from ParseFileSystem',
|
assert_equal 'from OtherFileSystem',
|
||||||
Template.parse("{% include template %}",file_system: ParseFileSystem.new).render!({})
|
Template.parse("{% include template %}",file_system: ParseFileSystem.new).render!({}, :registers => {:file_system => OtherFileSystem.new})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_include_tag_with
|
def test_include_tag_with
|
||||||
|
|||||||
Reference in New Issue
Block a user