diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 73bfc5aa..ac3d7da5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -461,7 +461,7 @@ module ApplicationHelper only_path = options.delete(:only_path) == false ? false : true begin - ChiliProject::Liquid::Legacy.run_macros(text) + text = ChiliProject::Liquid::Legacy.run_macros(text) liquid_template = ChiliProject::Liquid::Template.parse(text) liquid_variables = get_view_instance_variables_for_liquid liquid_variables.merge!({'current_user' => User.current}) diff --git a/lib/chili_project/liquid/legacy.rb b/lib/chili_project/liquid/legacy.rb index c2a23768..73642e56 100644 --- a/lib/chili_project/liquid/legacy.rb +++ b/lib/chili_project/liquid/legacy.rb @@ -22,11 +22,12 @@ module ChiliProject def self.run_macros(content) macros.each do |macro_name, macro| next unless macro[:match].present? && macro[:replace].present? - content.gsub!(macro[:match]) do |match| + content = content.gsub(macro[:match]) do |match| # Use block form so $1 and $2 are set properly "{#{macro[:replace]} #{macro[:new_name]} '#{$2}' #{macro[:replace]}}" end end + content end # Add support for a legacy macro syntax that was converted to liquid