Module: Hanami::Helpers::EscapeHelper
- Defined in:
- gems/gems/hanami-helpers-1.3.1/lib/hanami/helpers/escape_helper.rb,
gems/gems/hanami-helpers-1.3.3/lib/hanami/helpers/escape_helper.rb
Overview
Escape helpers
You can include this module inside your view and the view will have access all methods.
By including Hanami::Helpers::EscapeHelper
it will inject private methods as markup escape utilities.
Instance Method Summary collapse
-
#escape_html(input) ⇒ String
(also: #h)
private
Escape the given HTML tag content.
-
#escape_html_attribute(input) ⇒ String
(also: #ha)
private
Escape the given HTML tag attribute.
-
#escape_url(input, schemes = Utils::Escape::DEFAULT_URL_SCHEMES) ⇒ String
(also: #hu)
private
Escape an URL to be used in HTML attributes.
-
#raw(input) ⇒ Hanami::Utils::Escape::SafeString
private
Bypass escape.
Instance Method Details
#escape_html(input) ⇒ String (private) Also known as: h
Escape the given HTML tag content.
This should be used only for untrusted contents: user input.
This should be used only for tag contents. To escape tag attributes please use Hanami::Helpers::EscapeHelper#escape_html_attribute
.
#escape_html_attribute(input) ⇒ String (private) Also known as: ha
Escape the given HTML tag attribute.
This MUST be used for escaping HTML tag attributes.
This should be used only for untrusted contents: user input.
This can also be used to escape tag contents, but it’s slower. For this purpose use Hanami::Helpers::EscapeHelper#escape_html
.
#escape_url(input, schemes = Utils::Escape::DEFAULT_URL_SCHEMES) ⇒ String (private) Also known as: hu
Escape an URL to be used in HTML attributes
This allows only URLs with whitelisted schemes to pass the filter. Everything else is stripped.
Default schemes are:
-
http
-
https
-
mailto
If you want to allow a different set of schemes, you should pass it as second argument.
This should be used only for untrusted contents: user input.