module TextHelper
Ruby on Rails 8.0.4
Since v2.2.3Action View Text Helpers
The TextHelper module provides a set of methods for filtering, formatting and transforming strings, which can reduce the amount of inline Ruby code in your views. These helper methods extend Action View making them callable within your template files.
Sanitization
Most text helpers that generate HTML output sanitize the given input by default, but do not escape it. This means HTML tags will appear in the page but all malicious code will be removed. Let’s look at some examples using the simple_format method:
simple_format('<a href="http://example.com/">Example</a>') # => "<p><a href=\"http://example.com/\">Example</a></p>" simple_format('<a href="javascript:alert(\'no!\')">Example</a>') # => "<p><a>Example</a></p>"
If you want to escape all content, you should invoke the h method before calling the text helper.
simple_format h('<a href="http://example.com/">Example</a>') # => "<p><a href=\"http://example.com/\">Example</a></p>"
Includes
Extends
Methods (defined here)
- # concat
- # current_cycle
- # cycle
- # excerpt
- # highlight
- # pluralize
- # reset_cycle
- # safe_concat
- # simple_format
- # truncate
- # word_wrap
Private methods
(4)
Implementation detail — not part of the public API.
Used by
Included by (2)
Methods (inherited)
From ActionView::Helpers::OutputSafetyHelper (3)
- # raw
- # safe_join
- # to_sentence
From ActionView::Helpers::SanitizeHelper (4)
- # sanitize
- # sanitize_css
- # strip_links
- # strip_tags
From ActionView::Helpers::TagHelper (8)
- # cdata_section
- # class_names
- # content_tag
- # escape_once
- # tag
- # token_list
- self. build_tag_values
- self. ensure_valid_html5_tag_name
From ActiveSupport::Concern (3)
- # class_methods
- # included
- # prepended
From ActionView::Helpers::CaptureHelper (4)
- # capture
- # content_for
- # content_for?
- # provide