Module: RailsXss::SafeHelpers

Defined in:
lib/rails_xss/action_view.rb

Instance Method Summary collapse

Instance Method Details

#safe_helper(*names) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rails_xss/action_view.rb', line 73

def safe_helper(*names)
  names.each do |helper_method_name|
    aliased_target, punctuation = helper_method_name.to_s.sub(/([?!=])$/, ''), $1
    module_eval <<-END
      def #{aliased_target}_with_xss_safety#{punctuation}(*args, &block)
        raw(#{aliased_target}_without_xss_safety#{punctuation}(*args, &block))
      end
    END
    alias_method_chain helper_method_name, :xss_safety
  end
end