02ea6913e3
Conflicts: Gemfile.lock app/assets/javascripts/locomotive/models/page.js.coffee app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee app/models/locomotive/extensions/site/locales.rb app/models/locomotive/page.rb app/views/locomotive/pages/_form.html.haml config/initializers/haml.rb config/locales/default.ru.yml config/locales/formtastic.ru.yml doc/TODO lib/locomotive/haml.rb script/upgrade_v1.rb spec/dummy/config/initializers/haml.rb
35 lines
1.3 KiB
Ruby
35 lines
1.3 KiB
Ruby
require 'haml/helpers/action_view_mods'
|
|
|
|
# Only preserve whitespace in the tag's content: https://github.com/nex3/haml/pull/503
|
|
module ActionView
|
|
module Helpers #:nodoc:
|
|
module TagHelper
|
|
|
|
def content_tag_with_haml_and_preserve(name, content_or_options_with_block = nil, *args, &block)
|
|
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 name == 'textarea'
|
|
tab_down(haml_buffer.tabulation)
|
|
elsif 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
|