Skip to content
Snippets Groups Projects
Commit 9f4d12ff authored by Holger Just's avatar Holger Just
Browse files

[#734] Don't modify text inline.

This is not only a wee bit faster (yay!) but also allows use to deal with
frozen strings and doesn't change content which might inadvertently be saved
later on. And it fixes some broken tests on Ruby 1.9 :)
parent 28ce07b1
Tags
No related merge requests found
......@@ -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})
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment