ActionView::Helpers::TextHelper
Provides a set of methods for working with text strings that can help unburden the level of inline Ruby code in the templates. In the example below we iterate over a collection of posts provided to the template and print each title after making sure it doesn’t run longer than 20 characters:
<% for post in @posts %> Title: <%= truncate(post.title, 20) %> <% end %>
Constants
AUTO_LINK_RE = / ( # leading text <\\w+.*?>| # leading HTML tag, or [^=!:'"\\/]| # leading punctuation, or ^ # beginning of line ) ( (?:http[s]?:\\/\\/)| # protocol spec, or (?:www\\.) # www.* ) ( ([\\w]+[=?&\\/.-]?)* # url segment \\w+[\\/]? # url tail (?:\\#\\w*)? # trailing anchor ) ([[:punct:]]|\\s|<|$) # trailing text /x unless const_defined?(:AUTO_LINK_RE)
VERBOTEN_ATTRS = /^on/i unless defined?(VERBOTEN_ATTRS)
VERBOTEN_TAGS = %w(form script) unless defined?(VERBOTEN_TAGS)
Files
- actionpack/lib/action_view/helpers/text_helper.rb