liquid 3.0.0.rc1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/README.md +2 -2
- data/lib/liquid.rb +8 -0
- data/lib/liquid/block.rb +50 -46
- data/lib/liquid/block_body.rb +123 -0
- data/lib/liquid/condition.rb +12 -5
- data/lib/liquid/context.rb +75 -148
- data/lib/liquid/errors.rb +50 -2
- data/lib/liquid/expression.rb +33 -0
- data/lib/liquid/parser_switching.rb +31 -0
- data/lib/liquid/profiler.rb +159 -0
- data/lib/liquid/profiler/hooks.rb +23 -0
- data/lib/liquid/range_lookup.rb +22 -0
- data/lib/liquid/standardfilters.rb +29 -4
- data/lib/liquid/tag.rb +6 -25
- data/lib/liquid/tags/assign.rb +2 -1
- data/lib/liquid/tags/case.rb +1 -1
- data/lib/liquid/tags/if.rb +5 -5
- data/lib/liquid/tags/ifchanged.rb +1 -1
- data/lib/liquid/tags/include.rb +11 -1
- data/lib/liquid/tags/raw.rb +1 -4
- data/lib/liquid/tags/table_row.rb +1 -1
- data/lib/liquid/template.rb +55 -4
- data/lib/liquid/token.rb +18 -0
- data/lib/liquid/variable.rb +68 -41
- data/lib/liquid/variable_lookup.rb +78 -0
- data/lib/liquid/version.rb +1 -1
- data/test/integration/assign_test.rb +12 -1
- data/test/integration/blank_test.rb +1 -1
- data/test/integration/capture_test.rb +1 -1
- data/test/integration/context_test.rb +10 -11
- data/test/integration/drop_test.rb +29 -3
- data/test/integration/error_handling_test.rb +138 -41
- data/test/integration/filter_test.rb +7 -7
- data/test/integration/hash_ordering_test.rb +6 -8
- data/test/integration/output_test.rb +1 -1
- data/test/integration/parsing_quirks_test.rb +40 -18
- data/test/integration/render_profiling_test.rb +154 -0
- data/test/integration/security_test.rb +1 -1
- data/test/integration/standard_filter_test.rb +47 -1
- data/test/integration/tags/break_tag_test.rb +1 -1
- data/test/integration/tags/continue_tag_test.rb +1 -1
- data/test/integration/tags/for_tag_test.rb +2 -2
- data/test/integration/tags/if_else_tag_test.rb +23 -20
- data/test/integration/tags/include_tag_test.rb +24 -2
- data/test/integration/tags/increment_tag_test.rb +1 -1
- data/test/integration/tags/raw_tag_test.rb +1 -1
- data/test/integration/tags/standard_tag_test.rb +4 -4
- data/test/integration/tags/statements_test.rb +1 -1
- data/test/integration/tags/table_row_test.rb +1 -1
- data/test/integration/tags/unless_else_tag_test.rb +1 -1
- data/test/integration/template_test.rb +16 -4
- data/test/integration/variable_test.rb +11 -1
- data/test/test_helper.rb +59 -31
- data/test/unit/block_unit_test.rb +2 -5
- data/test/unit/condition_unit_test.rb +5 -1
- data/test/unit/context_unit_test.rb +13 -7
- data/test/unit/file_system_unit_test.rb +5 -5
- data/test/unit/i18n_unit_test.rb +3 -3
- data/test/unit/lexer_unit_test.rb +1 -1
- data/test/unit/module_ex_unit_test.rb +1 -1
- data/test/unit/parser_unit_test.rb +1 -1
- data/test/unit/regexp_unit_test.rb +1 -1
- data/test/unit/strainer_unit_test.rb +3 -2
- data/test/unit/tag_unit_test.rb +6 -1
- data/test/unit/tags/case_tag_unit_test.rb +1 -1
- data/test/unit/tags/for_tag_unit_test.rb +1 -1
- data/test/unit/tags/if_tag_unit_test.rb +1 -1
- data/test/unit/template_unit_test.rb +1 -1
- data/test/unit/tokenizer_unit_test.rb +10 -1
- data/test/unit/variable_unit_test.rb +49 -46
- metadata +71 -47
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderProfilingTest < Minitest::Test
|
4
|
+
include Liquid
|
5
|
+
|
6
|
+
class ProfilingFileSystem
|
7
|
+
def read_template_file(template_path, context)
|
8
|
+
"Rendering template {% assign template_name = '#{template_path}'%}\n{{ template_name }}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
Liquid::Template.file_system = ProfilingFileSystem.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_template_allows_flagging_profiling
|
17
|
+
t = Template.parse("{{ 'a string' | upcase }}")
|
18
|
+
t.render!
|
19
|
+
|
20
|
+
assert_nil t.profiler
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_parse_makes_available_simple_profiling
|
24
|
+
t = Template.parse("{{ 'a string' | upcase }}", :profile => true)
|
25
|
+
t.render!
|
26
|
+
|
27
|
+
assert_equal 1, t.profiler.length
|
28
|
+
|
29
|
+
node = t.profiler[0]
|
30
|
+
assert_equal " 'a string' | upcase ", node.code
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_render_ignores_raw_strings_when_profiling
|
34
|
+
t = Template.parse("This is raw string\nstuff\nNewline", :profile => true)
|
35
|
+
t.render!
|
36
|
+
|
37
|
+
assert_equal 0, t.profiler.length
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_profiling_includes_line_numbers_of_liquid_nodes
|
41
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", :profile => true)
|
42
|
+
t.render!
|
43
|
+
assert_equal 2, t.profiler.length
|
44
|
+
|
45
|
+
# {{ 'a string' | upcase }}
|
46
|
+
assert_equal 1, t.profiler[0].line_number
|
47
|
+
# {{ increment test }}
|
48
|
+
assert_equal 2, t.profiler[1].line_number
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_profiling_includes_line_numbers_of_included_partials
|
52
|
+
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
53
|
+
t.render!
|
54
|
+
|
55
|
+
included_children = t.profiler[0].children
|
56
|
+
|
57
|
+
# {% assign template_name = 'a_template' %}
|
58
|
+
assert_equal 1, included_children[0].line_number
|
59
|
+
# {{ template_name }}
|
60
|
+
assert_equal 2, included_children[1].line_number
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_profiling_times_the_rendering_of_tokens
|
64
|
+
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
65
|
+
t.render!
|
66
|
+
|
67
|
+
node = t.profiler[0]
|
68
|
+
refute_nil node.render_time
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_profiling_times_the_entire_render
|
72
|
+
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
73
|
+
t.render!
|
74
|
+
|
75
|
+
assert t.profiler.total_render_time >= 0, "Total render time was not calculated"
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_profiling_uses_include_to_mark_children
|
79
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", :profile => true)
|
80
|
+
t.render!
|
81
|
+
|
82
|
+
include_node = t.profiler[1]
|
83
|
+
assert_equal 2, include_node.children.length
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_profiling_marks_children_with_the_name_of_included_partial
|
87
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", :profile => true)
|
88
|
+
t.render!
|
89
|
+
|
90
|
+
include_node = t.profiler[1]
|
91
|
+
include_node.children.each do |child|
|
92
|
+
assert_equal "'a_template'", child.partial
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_profiling_supports_multiple_templates
|
97
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'b_template' %}", :profile => true)
|
98
|
+
t.render!
|
99
|
+
|
100
|
+
a_template = t.profiler[1]
|
101
|
+
a_template.children.each do |child|
|
102
|
+
assert_equal "'a_template'", child.partial
|
103
|
+
end
|
104
|
+
|
105
|
+
b_template = t.profiler[2]
|
106
|
+
b_template.children.each do |child|
|
107
|
+
assert_equal "'b_template'", child.partial
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_profiling_supports_rendering_the_same_partial_multiple_times
|
112
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'a_template' %}", :profile => true)
|
113
|
+
t.render!
|
114
|
+
|
115
|
+
a_template1 = t.profiler[1]
|
116
|
+
a_template1.children.each do |child|
|
117
|
+
assert_equal "'a_template'", child.partial
|
118
|
+
end
|
119
|
+
|
120
|
+
a_template2 = t.profiler[2]
|
121
|
+
a_template2.children.each do |child|
|
122
|
+
assert_equal "'a_template'", child.partial
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_can_iterate_over_each_profiling_entry
|
127
|
+
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", :profile => true)
|
128
|
+
t.render!
|
129
|
+
|
130
|
+
timing_count = 0
|
131
|
+
t.profiler.each do |timing|
|
132
|
+
timing_count += 1
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_equal 2, timing_count
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_profiling_marks_children_of_if_blocks
|
139
|
+
t = Template.parse("{% if true %} {% increment test %} {{ test }} {% endif %}", :profile => true)
|
140
|
+
t.render!
|
141
|
+
|
142
|
+
assert_equal 1, t.profiler.length
|
143
|
+
assert_equal 2, t.profiler[0].children.length
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_profiling_marks_children_of_for_blocks
|
147
|
+
t = Template.parse("{% for item in collection %} {{ item }} {% endfor %}", :profile => true)
|
148
|
+
t.render!({"collection" => ["one", "two"]})
|
149
|
+
|
150
|
+
assert_equal 1, t.profiler.length
|
151
|
+
# Will profile each invocation of the for block
|
152
|
+
assert_equal 2, t.profiler[0].children.length
|
153
|
+
end
|
154
|
+
end
|
@@ -41,7 +41,7 @@ class TestEnumerable < Liquid::Drop
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
class StandardFiltersTest < Test
|
44
|
+
class StandardFiltersTest < Minitest::Test
|
45
45
|
include Liquid
|
46
46
|
|
47
47
|
def setup
|
@@ -64,6 +64,34 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|
64
64
|
assert_equal '', @filters.upcase(nil)
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_slice
|
68
|
+
assert_equal 'oob', @filters.slice('foobar', 1, 3)
|
69
|
+
assert_equal 'oobar', @filters.slice('foobar', 1, 1000)
|
70
|
+
assert_equal '', @filters.slice('foobar', 1, 0)
|
71
|
+
assert_equal 'o', @filters.slice('foobar', 1, 1)
|
72
|
+
assert_equal 'bar', @filters.slice('foobar', 3, 3)
|
73
|
+
assert_equal 'ar', @filters.slice('foobar', -2, 2)
|
74
|
+
assert_equal 'ar', @filters.slice('foobar', -2, 1000)
|
75
|
+
assert_equal 'r', @filters.slice('foobar', -1)
|
76
|
+
assert_equal '', @filters.slice(nil, 0)
|
77
|
+
assert_equal '', @filters.slice('foobar', 100, 10)
|
78
|
+
assert_equal '', @filters.slice('foobar', -100, 10)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_slice_on_arrays
|
82
|
+
input = 'foobar'.split(//)
|
83
|
+
assert_equal %w{o o b}, @filters.slice(input, 1, 3)
|
84
|
+
assert_equal %w{o o b a r}, @filters.slice(input, 1, 1000)
|
85
|
+
assert_equal %w{}, @filters.slice(input, 1, 0)
|
86
|
+
assert_equal %w{o}, @filters.slice(input, 1, 1)
|
87
|
+
assert_equal %w{b a r}, @filters.slice(input, 3, 3)
|
88
|
+
assert_equal %w{a r}, @filters.slice(input, -2, 2)
|
89
|
+
assert_equal %w{a r}, @filters.slice(input, -2, 1000)
|
90
|
+
assert_equal %w{r}, @filters.slice(input, -1)
|
91
|
+
assert_equal %w{}, @filters.slice(input, 100, 10)
|
92
|
+
assert_equal %w{}, @filters.slice(input, -100, 10)
|
93
|
+
end
|
94
|
+
|
67
95
|
def test_truncate
|
68
96
|
assert_equal '1234...', @filters.truncate('1234567890', 7)
|
69
97
|
assert_equal '1234567890', @filters.truncate('1234567890', 20)
|
@@ -78,6 +106,7 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|
78
106
|
assert_equal ['A?Z'], @filters.split('A?Z', '~')
|
79
107
|
# Regexp works although Liquid does not support.
|
80
108
|
assert_equal ['A','Z'], @filters.split('AxZ', /x/)
|
109
|
+
assert_equal [], @filters.split(nil, ' ')
|
81
110
|
end
|
82
111
|
|
83
112
|
def test_escape
|
@@ -89,6 +118,11 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|
89
118
|
assert_equal '<strong>Hulk</strong>', @filters.escape_once('<strong>Hulk</strong>')
|
90
119
|
end
|
91
120
|
|
121
|
+
def test_url_encode
|
122
|
+
assert_equal 'foo%2B1%40example.com', @filters.url_encode('foo+1@example.com')
|
123
|
+
assert_equal nil, @filters.url_encode(nil)
|
124
|
+
end
|
125
|
+
|
92
126
|
def test_truncatewords
|
93
127
|
assert_equal 'one two three', @filters.truncatewords('one two three', 4)
|
94
128
|
assert_equal 'one two...', @filters.truncatewords('one two three', 2)
|
@@ -128,6 +162,13 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|
128
162
|
assert_equal [{"a" => "10"}, {"a" => "2"}], @filters.sort([{"a" => "10"}, {"a" => "2"}], "a")
|
129
163
|
end
|
130
164
|
|
165
|
+
def test_uniq
|
166
|
+
assert_equal [1,3,2,4], @filters.uniq([1,1,3,2,3,1,4,3,2,1])
|
167
|
+
assert_equal [{"a" => 1}, {"a" => 3}, {"a" => 2}], @filters.uniq([{"a" => 1}, {"a" => 3}, {"a" => 1}, {"a" => 2}], "a")
|
168
|
+
testdrop = TestDrop.new
|
169
|
+
assert_equal [testdrop], @filters.uniq([testdrop, TestDrop.new], 'test')
|
170
|
+
end
|
171
|
+
|
131
172
|
def test_reverse
|
132
173
|
assert_equal [4,3,2,1], @filters.reverse([1,2,3,4])
|
133
174
|
end
|
@@ -184,6 +225,11 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|
184
225
|
assert_template_result "213", '{{ foo | sort: "bar" | map: "foo" }}', "foo" => TestEnumerable.new
|
185
226
|
end
|
186
227
|
|
228
|
+
def test_first_and_last_call_to_liquid
|
229
|
+
assert_template_result 'foobar', '{{ foo | first }}', 'foo' => [ThingWithToLiquid.new]
|
230
|
+
assert_template_result 'foobar', '{{ foo | last }}', 'foo' => [ThingWithToLiquid.new]
|
231
|
+
end
|
232
|
+
|
187
233
|
def test_date
|
188
234
|
assert_equal 'May', @filters.date(Time.parse("2006-05-05 10:00:00"), "%B")
|
189
235
|
assert_equal 'June', @filters.date(Time.parse("2006-06-05 10:00:00"), "%B")
|
@@ -6,7 +6,7 @@ class ThingWithValue < Liquid::Drop
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
class ForTagTest < Test
|
9
|
+
class ForTagTest < Minitest::Test
|
10
10
|
include Liquid
|
11
11
|
|
12
12
|
def test_for
|
@@ -303,7 +303,7 @@ HERE
|
|
303
303
|
end
|
304
304
|
|
305
305
|
def test_bad_variable_naming_in_for_loop
|
306
|
-
|
306
|
+
assert_raises(Liquid::SyntaxError) do
|
307
307
|
Liquid::Template.parse('{% for a/b in x %}{% endfor %}')
|
308
308
|
end
|
309
309
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class IfElseTagTest < Test
|
3
|
+
class IfElseTagTest < Minitest::Test
|
4
4
|
include Liquid
|
5
5
|
|
6
6
|
def test_if
|
@@ -10,6 +10,11 @@ class IfElseTagTest < Test::Unit::TestCase
|
|
10
10
|
assert_template_result(' you rock ?','{% if false %} you suck {% endif %} {% if true %} you rock {% endif %}?')
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_literal_comparisons
|
14
|
+
assert_template_result(' NO ','{% assign v = false %}{% if v %} YES {% else %} NO {% endif %}')
|
15
|
+
assert_template_result(' YES ','{% assign v = nil %}{% if v == nil %} YES {% else %} NO {% endif %}')
|
16
|
+
end
|
17
|
+
|
13
18
|
def test_if_else
|
14
19
|
assert_template_result(' YES ','{% if false %} NO {% else %} YES {% endif %}')
|
15
20
|
assert_template_result(' YES ','{% if true %} YES {% else %} NO {% endif %}')
|
@@ -37,25 +42,19 @@ class IfElseTagTest < Test::Unit::TestCase
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def test_comparison_of_strings_containing_and_or_or
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
assert_template_result(' YES ',"{% if #{awful_markup} %} YES {% endif %}", assigns)
|
44
|
-
end
|
45
|
+
awful_markup = "a == 'and' and b == 'or' and c == 'foo and bar' and d == 'bar or baz' and e == 'foo' and foo and bar"
|
46
|
+
assigns = {'a' => 'and', 'b' => 'or', 'c' => 'foo and bar', 'd' => 'bar or baz', 'e' => 'foo', 'foo' => true, 'bar' => true}
|
47
|
+
assert_template_result(' YES ',"{% if #{awful_markup} %} YES {% endif %}", assigns)
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_comparison_of_expressions_starting_with_and_or_or
|
48
51
|
assigns = {'order' => {'items_count' => 0}, 'android' => {'name' => 'Roy'}}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
assert_template_result( "YES",
|
56
|
-
"{% if order.items_count == 0 %}YES{% endif %}",
|
57
|
-
assigns)
|
58
|
-
end
|
52
|
+
assert_template_result( "YES",
|
53
|
+
"{% if android.name == 'Roy' %}YES{% endif %}",
|
54
|
+
assigns)
|
55
|
+
assert_template_result( "YES",
|
56
|
+
"{% if order.items_count == 0 %}YES{% endif %}",
|
57
|
+
assigns)
|
59
58
|
end
|
60
59
|
|
61
60
|
def test_if_and
|
@@ -135,31 +134,35 @@ class IfElseTagTest < Test::Unit::TestCase
|
|
135
134
|
end
|
136
135
|
|
137
136
|
def test_syntax_error_no_variable
|
138
|
-
|
137
|
+
assert_raises(SyntaxError){ assert_template_result('', '{% if jerry == 1 %}')}
|
139
138
|
end
|
140
139
|
|
141
140
|
def test_syntax_error_no_expression
|
142
|
-
|
141
|
+
assert_raises(SyntaxError) { assert_template_result('', '{% if %}') }
|
143
142
|
end
|
144
143
|
|
145
144
|
def test_if_with_custom_condition
|
145
|
+
original_op = Condition.operators['contains']
|
146
146
|
Condition.operators['contains'] = :[]
|
147
147
|
|
148
148
|
assert_template_result('yes', %({% if 'bob' contains 'o' %}yes{% endif %}))
|
149
149
|
assert_template_result('no', %({% if 'bob' contains 'f' %}yes{% else %}no{% endif %}))
|
150
150
|
ensure
|
151
|
-
Condition.operators
|
151
|
+
Condition.operators['contains'] = original_op
|
152
152
|
end
|
153
153
|
|
154
154
|
def test_operators_are_ignored_unless_isolated
|
155
|
+
original_op = Condition.operators['contains']
|
155
156
|
Condition.operators['contains'] = :[]
|
156
157
|
|
157
158
|
assert_template_result('yes',
|
158
159
|
%({% if 'gnomeslab-and-or-liquid' contains 'gnomeslab-and-or-liquid' %}yes{% endif %}))
|
160
|
+
ensure
|
161
|
+
Condition.operators['contains'] = original_op
|
159
162
|
end
|
160
163
|
|
161
164
|
def test_operators_are_whitelisted
|
162
|
-
|
165
|
+
assert_raises(SyntaxError) do
|
163
166
|
assert_template_result('', %({% if 1 or throw or or 1 %}yes{% endif %}))
|
164
167
|
end
|
165
168
|
end
|
@@ -27,6 +27,9 @@ class TestFileSystem
|
|
27
27
|
when "pick_a_source"
|
28
28
|
"from TestFileSystem"
|
29
29
|
|
30
|
+
when 'assignments'
|
31
|
+
"{% assign foo = 'bar' %}"
|
32
|
+
|
30
33
|
else
|
31
34
|
template_path
|
32
35
|
end
|
@@ -65,7 +68,7 @@ class CustomInclude < Liquid::Tag
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
class IncludeTagTest < Test
|
71
|
+
class IncludeTagTest < Minitest::Test
|
69
72
|
include Liquid
|
70
73
|
|
71
74
|
def setup
|
@@ -108,6 +111,10 @@ class IncludeTagTest < Test::Unit::TestCase
|
|
108
111
|
'echo1' => 'test123', 'more_echos' => { "echo2" => 'test321'}
|
109
112
|
end
|
110
113
|
|
114
|
+
def test_included_templates_assigns_variables
|
115
|
+
assert_template_result "bar", "{% include 'assignments' %}{{ foo }}"
|
116
|
+
end
|
117
|
+
|
111
118
|
def test_nested_include_tag
|
112
119
|
assert_template_result "body body_detail", "{% include 'body' %}"
|
113
120
|
|
@@ -132,7 +139,7 @@ class IncludeTagTest < Test::Unit::TestCase
|
|
132
139
|
|
133
140
|
Liquid::Template.file_system = infinite_file_system.new
|
134
141
|
|
135
|
-
|
142
|
+
assert_raises(Liquid::StackLevelError, SystemStackError) do
|
136
143
|
Template.parse("{% include 'loop' %}").render!
|
137
144
|
end
|
138
145
|
|
@@ -209,4 +216,19 @@ class IncludeTagTest < Test::Unit::TestCase
|
|
209
216
|
a.render!
|
210
217
|
assert_empty a.errors
|
211
218
|
end
|
219
|
+
|
220
|
+
def test_passing_options_to_included_templates
|
221
|
+
assert_raises(Liquid::SyntaxError) do
|
222
|
+
Template.parse("{% include template %}", error_mode: :strict).render!("template" => '{{ "X" || downcase }}')
|
223
|
+
end
|
224
|
+
with_error_mode(:lax) do
|
225
|
+
assert_equal 'x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: true).render!("template" => '{{ "X" || downcase }}')
|
226
|
+
end
|
227
|
+
assert_raises(Liquid::SyntaxError) do
|
228
|
+
Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:locale]).render!("template" => '{{ "X" || downcase }}')
|
229
|
+
end
|
230
|
+
with_error_mode(:lax) do
|
231
|
+
assert_equal 'x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:error_mode]).render!("template" => '{{ "X" || downcase }}')
|
232
|
+
end
|
233
|
+
end
|
212
234
|
end # IncludeTagTest
|