Sha256: 4a0e5cd3cfbf7fe082f528e400917130ab339f86ff9fe4355461524593fd68e7
Contents?: true
Size: 1001 Bytes
Versions: 11
Compression:
Stored size: 1001 Bytes
Contents
# @Opulent module Opulent module Utils # Used by escape_html # EscapeHTML = { '&' => '&', '"' => '"', '\'' => ''', '<' => '<', '>' => '>' }.freeze # Pattern matching for html escape characters EscapeHTMLPattern = Regexp.union(*EscapeHTML.keys) # Ruby interpolation pattern InterpolationPattern = /\#\{([^}]+)\}/ # @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 EscapeHTMLPattern, EscapeHTML end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems