preserve whitespace in textarea tags (HAML/Rails bug)
This commit is contained in:
parent
1ae9557515
commit
f973ccef1b
@ -1 +1,2 @@
|
||||
# Haml::Template.options[:ugly] = true # improve performance in dev
|
||||
Haml::Template.options[:format] = :html5
|
||||
Haml::Template.options[:ugly] = true # improve performance in dev
|
@ -2,6 +2,7 @@ require 'locomotive/version'
|
||||
require 'locomotive/core_ext'
|
||||
require 'locomotive/configuration'
|
||||
require 'locomotive/logger'
|
||||
require 'locomotive/haml'
|
||||
require 'locomotive/formtastic'
|
||||
require 'locomotive/dragonfly'
|
||||
require 'locomotive/kaminari'
|
||||
|
34
lib/locomotive/haml.rb
Normal file
34
lib/locomotive/haml.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require 'haml/helpers/action_view_mods'
|
||||
|
||||
module ActionView
|
||||
module Helpers
|
||||
module TagHelper
|
||||
|
||||
# Only preserve whitespace in the tag's content: https://github.com/nex3/haml/pull/503
|
||||
def content_tag_with_haml_and_preserve(name, content_or_options_with_block = nil, *args, &block)
|
||||
Rails.logger.debug("[content_tag_with_haml_and_preserve / ENGINE] #{name} / #{respond_to?(:content_tag_with_haml)} / #{respond_to?(:content_tag_without_haml)}")
|
||||
|
||||
return content_tag_without_haml(name, content_or_options_with_block, *args, &block) unless is_haml?
|
||||
|
||||
preserve = haml_buffer.options[:preserve].include?(name.to_s)
|
||||
|
||||
if block_given?
|
||||
if block_is_haml?(block) && preserve
|
||||
content_tag_without_haml(name, content_or_options_with_block, *args) {preserve(&block)}
|
||||
else
|
||||
content_tag_without_haml(name, content_or_options_with_block, *args, &block)
|
||||
end
|
||||
else
|
||||
if preserve && content_or_options_with_block
|
||||
content_or_options_with_block = Haml::Helpers.preserve(content_or_options_with_block)
|
||||
end
|
||||
content_tag_without_haml(name, content_or_options_with_block, *args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :content_tag_without_haml_and_preserve, :content_tag
|
||||
alias_method :content_tag, :content_tag_with_haml_and_preserve
|
||||
alias_method :content_tag_with_haml, :content_tag_with_haml_and_preserve
|
||||
end
|
||||
end
|
||||
end
|
@ -1 +1,2 @@
|
||||
Haml::Template.options[:format] = :html5
|
||||
Haml::Template.options[:ugly] = true # improve performance in dev
|
Loading…
Reference in New Issue
Block a user