Sha256: 27339e2d53a42c55c4cc5020edede638f1c5c0633d0f9c30d260dc047680fe38
Contents?: true
Size: 1020 Bytes
Versions: 27
Compression:
Stored size: 1020 Bytes
Contents
# @Opulent module Opulent # @Utils module Utils # Used by escape_html # ESCAPE_HTML = { '&' => '&', '"' => '"', '\'' => ''', '<' => '<', '>' => '>' }.freeze # Pattern matching for html escape characters ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys) # Ruby interpolation pattern INTERPOLATION_PATTERN = /(\#\{[^}]+\})/ # @Utils class << self if defined?(EscapeUtils) # Returns an escaped copy of `html`. # # @param html [String] The string to escape # @return [String] The escaped string def escape(html) EscapeUtils.escape_html html.to_s.chomp, false end else # Returns an escaped copy of `html`. # # @param html [String] The string to escape # @return [String] The escaped string def escape(html) html.to_s.chomp.gsub ESCAPE_HTML_PATTERN, ESCAPE_HTML end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems