class Haml::Compiler::ScriptCompiler
def self.find_and_preserve(input, tags)
def self.find_and_preserve(input, tags) tags = tags.map { |tag| Regexp.escape(tag) }.join('|') re = /<(#{tags})([^>]*)>(.*?)(<\/\1>)/im input.to_s.gsub(re) do |s| s =~ re # Can't rely on $1, etc. existing since Rails' SafeBuffer#gsub is incompatible "<#{$1}#{$2}>#{Haml::Helpers.preserve($3)}</#{$1}>" end end