[#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 :)
This commit is contained in:
parent
28ce07b1dd
commit
9f4d12ffdf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue