From 46fd63da5f149f5c6485dfc26982a9e2b5651a48 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Mon, 19 Oct 2020 12:07:39 -0400 Subject: [PATCH] Fix strict parsing of find variable with a name expression --- lib/liquid/parser.rb | 5 +++++ test/integration/variable_test.rb | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index b43576e..609601a 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -52,6 +52,11 @@ module Liquid when :id str = consume str << variable_lookups + when :open_square + str = consume + str << expression + str << consume(:close_square) + str << variable_lookups when :string, :number consume when :open_round diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index 45268bd..168f43a 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -95,4 +95,8 @@ class VariableTest < Minitest::Test def test_render_symbol assert_template_result('bar', '{{ foo }}', 'foo' => :bar) end + + def test_dynamic_find_var + assert_template_result('bar', '{{ [key] }}', 'key' => 'foo', 'foo' => 'bar') + end end