Attempt to strict parse variables before lax parsing in lax error mode (#1338)

This commit is contained in:
Dylan Thacker-Smith
2020-10-28 10:37:00 -04:00
committed by GitHub
parent 1d63d5db5f
commit 7754d5aef5
4 changed files with 23 additions and 1 deletions
+5
View File
@@ -48,6 +48,11 @@ class AssignTest < Minitest::Test
end
end
def test_expression_with_whitespace_in_square_brackets
source = "{% assign r = a[ 'b' ] %}{{ r }}"
assert_template_result('result', source, 'a' => { 'b' => 'result' })
end
def test_assign_score_exceeding_resource_limit
t = Template.parse("{% assign foo = 42 %}{% assign bar = 23 %}")
t.resource_limits.assign_score_limit = 1
+5
View File
@@ -21,6 +21,11 @@ class VariableTest < Minitest::Test
assert_equal(' worked wonderfully ', template.render!('test' => 'worked wonderfully'))
end
def test_expression_with_whitespace_in_square_brackets
assert_template_result('result', "{{ a[ 'b' ] }}", 'a' => { 'b' => 'result' })
assert_template_result('result', "{{ a[ [ 'b' ] ] }}", 'b' => 'c', 'a' => { 'c' => 'result' })
end
def test_ignore_unknown
template = Template.parse(%({{ test }}))
assert_equal('', template.render!)