From 722c68f9de0747d40f6cc6342ea62705cfc4a927 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Sat, 8 Mar 2008 15:27:59 -0800 Subject: [PATCH] Make the content_tag mods not die outside Haml. --- lib/haml/helpers/action_view_mods.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/haml/helpers/action_view_mods.rb b/lib/haml/helpers/action_view_mods.rb index b9ea3dc5..fa0b9fc7 100644 --- a/lib/haml/helpers/action_view_mods.rb +++ b/lib/haml/helpers/action_view_mods.rb @@ -43,7 +43,11 @@ if defined?(ActionView) and not defined?(Merb::Plugins) module TagHelper def content_tag_with_haml(name, *args, &block) content = content_tag_without_haml(name, *args, &block) - content = Haml::Helpers.preserve content if haml_buffer.options[:preserve].include?(name.to_s) + + if is_haml? && haml_buffer.options[:preserve].include?(name.to_s) + content = Haml::Helpers.preserve content + end + content end alias_method :content_tag_without_haml, :content_tag @@ -57,6 +61,10 @@ if defined?(ActionView) and not defined?(Merb::Plugins) @template_object.send :haml_buffer end + def is_haml? + @template_object.send :is_haml? + end + alias_method :content_tag_without_haml, :content_tag alias_method :content_tag, :content_tag_with_haml end