Sha256: 675ef95c8ec60cb895ebe87099d2c0ad4f211ec014f5259f5cb6d34c2ad1460a

Contents?: true

Size: 1.3 KB

Versions: 181

Compression:

Stored size: 1.3 KB

Contents

require 'active_support/core_ext/string/output_safety'

module ActionView #:nodoc:
  # = Action View Raw Output Helper
  module Helpers #:nodoc:
    module OutputSafetyHelper
      # This method outputs without escaping a string. Since escaping tags is
      # now default, this can be used when you don't want Rails to automatically
      # escape tags. This is not recommended if the data is coming from the user's
      # input.
      #
      # For example:
      #
      # <%=raw @user.name %>
      def raw(stringish)
        stringish.to_s.html_safe
      end

      # This method returns a html safe string similar to what <tt>Array#join</tt>
      # would return. All items in the array, including the supplied separator, are
      # html escaped unless they are html safe, and the returned string is marked
      # as html safe.
      #
      #   safe_join(["<p>foo</p>".html_safe, "<p>bar</p>"], "<br />")
      #   # => "<p>foo</p>&lt;br /&gt;&lt;p&gt;bar&lt;/p&gt;"
      #
      #   safe_join(["<p>foo</p>".html_safe, "<p>bar</p>".html_safe], "<br />".html_safe)
      #   # => "<p>foo</p><br /><p>bar</p>"
      #
      def safe_join(array, sep=$,)
        sep ||= "".html_safe
        sep = ERB::Util.html_escape(sep)

        array.map { |i| ERB::Util.html_escape(i) }.join(sep).html_safe
      end
    end
  end
end

Version data entries

181 entries across 142 versions & 18 rubygems

Version Path
actionpack-3.2.22.5 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.22.4 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.22.3 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.22.2 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.22.1 lib/action_view/helpers/output_safety_helper.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.22 lib/action_view/helpers/output_safety_helper.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.12/lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.21 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.20 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.19 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.18 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.17 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.16 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.15 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.15.rc3 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.15.rc2 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.15.rc1 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.14 lib/action_view/helpers/output_safety_helper.rb
actionpack-3.2.14.rc2 lib/action_view/helpers/output_safety_helper.rb