cycle

cycle(first_value, *values) Instance Public methods Creates a Cycle object whose to_s method cycles through elements of an array every time it is called. This can be used for example, to alternate classes for table rows. You can use named cycles to allow nesting in loops. Passing a Hash as the last parameter with a :name key will create a named cycle. The default name for a cycle without a :name key is "default". You can manually reset a cycle by calling #reset_cycle and passing th

excerpt

excerpt(text, phrase, options = {}) Instance Public methods Extracts an excerpt from text that matches the first instance of phrase. The :radius option expands the excerpt on each side of the first occurrence of phrase by the number of characters defined in :radius (which defaults to 100). If the excerpt radius overflows the beginning or end of the text, then the :omission option (which defaults to ââ¦â) will be prepended/appended accordingly. Use the :separator option to choose th

highlight

highlight(text, phrases, options = {}) Instance Public methods Highlights one or more phrases everywhere in text by inserting it into a :highlighter string. The highlighter can be specialized by passing :highlighter as a single-quoted string with \1 where the phrase is to be inserted (defaults to '<mark>1</mark>') highlight('You searched for: rails', 'rails') # => You searched for: <mark>rails</mark> highlight('You searched for: ruby, rails, dhh', 'actio

pluralize

pluralize(count, singular, plural = nil) Instance Public methods Attempts to pluralize the singular word unless count is 1. If plural is supplied, it will use that when count is > 1, otherwise it will use the Inflector to determine the plural form. pluralize(1, 'person') # => 1 person pluralize(2, 'person') # => 2 people pluralize(3, 'person', 'users') # => 3 users pluralize(0, 'person') # => 0 people

reset_cycle

reset_cycle(name = "default") Instance Public methods Resets a cycle so that it starts from the first element the next time it is called. Pass in name to reset a named cycle. # Alternate CSS classes for even and odd numbers... @items = [[1,2,3,4], [5,6,3], [3,4,5,6,7,4]] <table> <% @items.each do |item| %> <tr class="<%= cycle("even", "odd") -%>"> <% item.each do |value| %> <span style="color:<%= cycle("#333", "#666", "#999", name

safe_concat

safe_concat(string) Instance Public methods

simple_format

simple_format(text, html_options = {}, options = {}) Instance Public methods Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines(\n\n) are considered as a paragraph and wrapped in <p> tags. One newline (\n) is considered as a linebreak and a <br /> tag is appended. This method does not remove the newlines from the text. You can pass any HTML attributes into html_options. These will be added to all created paragraphs. Option

truncate

truncate(text, options = {}, &block) Instance Public methods Truncates a given text after a given :length if text is longer than :length (defaults to 30). The last characters will be replaced with the :omission (defaults to ââ¦â) for a total length not exceeding :length. Pass a :separator to truncate text at a natural break. Pass a block if you want to show extra content when the text is truncated. The result is marked as HTML-safe, but it is escaped by default, unless :escape

word_wrap

word_wrap(text, options = {}) Instance Public methods Wraps the text into lines no longer than line_width width. This method breaks on the first whitespace character that does not exceed line_width (which is 80 by default). word_wrap('Once upon a time') # => Once upon a time word_wrap('Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...') # => Once upon a t

l

l(*args) Instance Public methods Alias for: localize