ActionView::Helpers::TextHelper
def excerpt(text, phrase, options = {})

Description

Returns an excerpt of the string around the match.

Arguments

Changing a value updates the ERB and HTML.

Extracts the first match of the phrase argument, along with as much text on each side as the :radius option allows. Adds ... to each end that is cut off. Returns nil if nothing matches. The returned string is not escaped.
A string matches case-insensitively. A regular expression is used as is.
options= {}
5
The length to keep on each side of the match (defaults to 100). With the :separator option, it counts pieces split by that string instead of characters.
" "
When given, extracts whole pieces split by this string (for example, to avoid cutting words in half).
"<>"
Uses the given string instead of .... The returned string is not escaped, so the &lt;&gt; in the HTML section comes from <%= %>.
Options not listed here are ignored.

ERB

Changes from the previous output: Added Removed Changed


          

HTML