Module: Temple::Utils
Constant Summary collapse
- ESCAPE_HTML =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Used by escape_html
{ "&" => "&", '"' => """, "'" => "'", "<" => "<", ">" => ">" }.freeze
- ESCAPE_HTML_PATTERN =
Regexp.union(*ESCAPE_HTML.keys)
Instance Method Summary collapse
-
#escape_html(html) ⇒ String
Returns an escaped copy of ‘html`.
-
#escape_html_safe(html) ⇒ String
Returns an escaped copy of ‘html`.
Instance Method Details
#escape_html(html) ⇒ String
Returns an escaped copy of ‘html`.
30 31 32 |
# File 'lib/deprecation_collector/web/utils.rb', line 30 def escape_html(html) CGI.escapeHTML(html.to_s) end |
#escape_html_safe(html) ⇒ String
Returns an escaped copy of ‘html`. Strings which are declared as html_safe are not escaped.
20 21 22 23 |
# File 'lib/deprecation_collector/web/utils.rb', line 20 def escape_html_safe(html) s = html.to_s s.html_safe? || html.html_safe? ? s : escape_html(s) end |