lib/deface/action_view_extensions.rb in deface-0.9.1 vs lib/deface/action_view_extensions.rb in deface-1.0.0.rc1

- old
+ new

@@ -1,10 +1,10 @@ ActionView::Template.class_eval do alias_method :initialize_without_deface, :initialize def initialize(source, identifier, handler, details) - if Rails.application.config.deface.enabled + if Rails.application.config.deface.enabled && should_be_defaced?(handler) haml = handler.to_s == "Haml::Plugin" processed_source = Deface::Override.apply(source, details, true, haml ) if haml && processed_source != source @@ -47,9 +47,15 @@ def method_name deface_hash = Deface::Override.digest(:virtual_path => @virtual_path) #we digest the whole method name as if it gets too long there's problems "_#{Digest::MD5.new.update("#{deface_hash}_#{method_name_without_deface}").hexdigest}" + end + + private + + def should_be_defaced?(handler) + handler.to_s.demodulize == "ERB" || handler.class.to_s.demodulize == "ERB" || handler.to_s == "Haml::Plugin" end end #fix for Rails 3.1 not setting virutal_path anymore (BOO!) if defined?(ActionView::Resolver::Path)