lib/grntest/template-evaluator.rb in grntest-1.5.6 vs lib/grntest/template-evaluator.rb in grntest-1.5.7

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2016-2023 Sutou Kouhei <kou@clear-code.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. @@ -17,10 +17,14 @@ class TemplateEvaluator def initialize(template) @template = template end - def evaluate(i) - eval(@template) + def evaluate(**local_variables) + _binding = binding + local_variables.each do |name, value| + _binding.local_variable_set(name, value) + end + _binding.eval(@template) end end end