class Haml::Buffer

def fix_textareas!(input)

Other tags:
    Private: -

Other tags:
    Since: - Haml 4.0.1

Parameters:
  • input (String) -- The text to process
def fix_textareas!(input)
  return input unless toplevel? && input.include?('<textarea'.freeze)
  pattern = /<(textarea)([^>]*)>(\n|&#x000A;)(.*?)<\/textarea>/im
  input.gsub!(pattern) do |s|
    match = pattern.match(s)
    content = match[4]
    if match[3] == '&#x000A;'
      content.sub!(/\A /, '&#x0020;')
    else
      content.sub!(/\A[ ]*/, '')
    end
    "<#{match[1]}#{match[2]}>\n#{content}</#{match[1]}>"
  end
  input
end