Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 8b99df826c3b6cf56a1caaae5f931d50 > files > 899

ruby-actionpack-2.3.4-1mdv2010.0.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::TextHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::TextHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/lib/action_view/helpers/text_helper_rb.html">
                lib/action_view/helpers/text_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The <a href="TextHelper.html">TextHelper</a> 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 ActionView making them callable within your template files.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000559">auto_link</a>&nbsp;&nbsp;
      <a href="#M000549">concat</a>&nbsp;&nbsp;
      <a href="#M000561">current_cycle</a>&nbsp;&nbsp;
      <a href="#M000560">cycle</a>&nbsp;&nbsp;
      <a href="#M000552">excerpt</a>&nbsp;&nbsp;
      <a href="#M000551">highlight</a>&nbsp;&nbsp;
      <a href="#M000557">markdown</a>&nbsp;&nbsp;
      <a href="#M000553">pluralize</a>&nbsp;&nbsp;
      <a href="#M000562">reset_cycle</a>&nbsp;&nbsp;
      <a href="#M000558">simple_format</a>&nbsp;&nbsp;
      <a href="#M000555">textilize</a>&nbsp;&nbsp;
      <a href="#M000556">textilize_without_paragraph</a>&nbsp;&nbsp;
      <a href="#M000550">truncate</a>&nbsp;&nbsp;
      <a href="#M000554">word_wrap</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">AUTO_LINK_RE</td>
          <td>=</td>
          <td class="context-item-value">%r{             ( https?:// | www\. )             [^\s&lt;]+           }x unless const_defined?(:AUTO_LINK_RE)</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">BRACKETS</td>
          <td>=</td>
          <td class="context-item-value">{ ']' =&gt; '[', ')' =&gt; '(', '}' =&gt; '{' }</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000559" class="method-detail">
        <a name="M000559"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000559.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000559.html');return false;">
          <span class="method-name">auto_link</span><span class="method-args">(text, *args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Turns all URLs and e-mail addresses into clickable links. The
<tt>:link</tt> option will limit what should be linked. You can add HTML
attributes to the links using <tt>:href_options</tt>. Possible values for
<tt>:link</tt> are <tt>:all</tt> (default), <tt>:email_addresses</tt>, and
<tt>:urls</tt>. If a block is given, each URL and e-mail address is yielded
and the result is used as the link text.
</p>
<h4>Examples</h4>
<pre>
  auto_link(&quot;Go to http://www.rubyonrails.org and say hello to david@loudthinking.com&quot;)
  # =&gt; &quot;Go to &lt;a href=\&quot;http://www.rubyonrails.org\&quot;&gt;http://www.rubyonrails.org&lt;/a&gt; and
  #     say hello to &lt;a href=\&quot;mailto:david@loudthinking.com\&quot;&gt;david@loudthinking.com&lt;/a&gt;&quot;

  auto_link(&quot;Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com&quot;, :link =&gt; :urls)
  # =&gt; &quot;Visit &lt;a href=\&quot;http://www.loudthinking.com/\&quot;&gt;http://www.loudthinking.com/&lt;/a&gt;
  #     or e-mail david@loudthinking.com&quot;

  auto_link(&quot;Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com&quot;, :link =&gt; :email_addresses)
  # =&gt; &quot;Visit http://www.loudthinking.com/ or e-mail &lt;a href=\&quot;mailto:david@loudthinking.com\&quot;&gt;david@loudthinking.com&lt;/a&gt;&quot;

  post_body = &quot;Welcome to my new blog at http://www.myblog.com/.  Please e-mail me at me@email.com.&quot;
  auto_link(post_body, :href_options =&gt; { :target =&gt; '_blank' }) do |text|
    truncate(text, 15)
  end
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot; target=\&quot;_blank\&quot;&gt;http://www.m...&lt;/a&gt;.
        Please e-mail me at &lt;a href=\&quot;mailto:me@email.com\&quot;&gt;me@email.com&lt;/a&gt;.&quot;
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M000559">auto_link</a></tt>
with the old API that accepts the <tt>link</tt> as its optional second
parameter and the <tt>html_options</tt> hash as its optional third
parameter:
</p>
<pre>
  post_body = &quot;Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.&quot;
  auto_link(post_body, :urls)     # =&gt; Once upon\na time
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot;&gt;http://www.myblog.com&lt;/a&gt;.
        Please e-mail me at me@email.com.&quot;

  auto_link(post_body, :all, :target =&gt; &quot;_blank&quot;)     # =&gt; Once upon\na time
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot; target=\&quot;_blank\&quot;&gt;http://www.myblog.com&lt;/a&gt;.
        Please e-mail me at &lt;a href=\&quot;mailto:me@email.com\&quot;&gt;me@email.com&lt;/a&gt;.&quot;
</pre>
        </div>
      </div>

      <div id="method-M000549" class="method-detail">
        <a name="M000549"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000549.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000549.html');return false;">
          <span class="method-name">concat</span><span class="method-args">(string, unused_binding = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The preferred method of outputting text in your views is to use the &lt;%=
&quot;text&quot; %&gt; eRuby syntax. The regular <em>puts</em> and
<em>print</em> methods do not operate as expected in an eRuby code block.
If you absolutely must output text within a non-output code block (i.e.,
&lt;% %&gt;), you can use the <a href="TextHelper.html#M000549">concat</a>
method.
</p>
<h4>Examples</h4>
<pre>
  &lt;%
      concat &quot;hello&quot;
      # is the equivalent of &lt;%= &quot;hello&quot; %&gt;

      if (logged_in == true):
        concat &quot;Logged in!&quot;
      else
        concat link_to('login', :action =&gt; login)
      end
      # will either display &quot;Logged in!&quot; or a login link
  %&gt;
</pre>
        </div>
      </div>

      <div id="method-M000561" class="method-detail">
        <a name="M000561"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000561.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000561.html');return false;">
          <span class="method-name">current_cycle</span><span class="method-args">(name = &quot;default&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the current <a href="TextHelper.html#M000560">cycle</a> string
after a <a href="TextHelper.html#M000560">cycle</a> has been started.
Useful for complex table highlighing or any other design need which
requires the current <a href="TextHelper.html#M000560">cycle</a> string in
more than one place.
</p>
<h4>Example</h4>
<pre>
  # Alternate background colors
  @items = [1,2,3,4]
  &lt;% @items.each do |item| %&gt;
    &lt;div style=&quot;background-color:&lt;%= cycle(&quot;red&quot;,&quot;white&quot;,&quot;blue&quot;) %&gt;&quot;&gt;
      &lt;span style=&quot;background-color:&lt;%= current_cycle %&gt;&quot;&gt;&lt;%= item %&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
</pre>
        </div>
      </div>

      <div id="method-M000560" class="method-detail">
        <a name="M000560"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000560.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000560.html');return false;">
          <span class="method-name">cycle</span><span class="method-args">(first_value, *values)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a Cycle object whose <em>to_s</em> 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 <tt>:name</tt> key
will create a named <a href="TextHelper.html#M000560">cycle</a>. The
default name for a <a href="TextHelper.html#M000560">cycle</a> without a
+:name+ key is <tt>&quot;default&quot;</tt>. You can manually reset a <a
href="TextHelper.html#M000560">cycle</a> by calling <a
href="TextHelper.html#M000562">reset_cycle</a> and passing the name of the
<a href="TextHelper.html#M000560">cycle</a>. The current <a
href="TextHelper.html#M000560">cycle</a> string can be obtained anytime
using the <a href="TextHelper.html#M000561">current_cycle</a> method.
</p>
<h4>Examples</h4>
<pre>
  # Alternate CSS classes for even and odd numbers...
  @items = [1,2,3,4]
  &lt;table&gt;
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;) -%&gt;&quot;&gt;
      &lt;td&gt;item&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;

  # Cycle CSS classes for rows, and text colors for values within each row
  @items = x = [{:first =&gt; 'Robert', :middle =&gt; 'Daniel', :last =&gt; 'James'},
               {:first =&gt; 'Emily', :middle =&gt; 'Shannon', :maiden =&gt; 'Pike', :last =&gt; 'Hicks'},
              {:first =&gt; 'June', :middle =&gt; 'Dae', :last =&gt; 'Jones'}]
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;, :name =&gt; &quot;row_class&quot;) -%&gt;&quot;&gt;
      &lt;td&gt;
        &lt;% item.values.each do |value| %&gt;
          &lt;%# Create a named cycle &quot;colors&quot; %&gt;
          &lt;span style=&quot;color:&lt;%= cycle(&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, :name =&gt; &quot;colors&quot;) -%&gt;&quot;&gt;
            &lt;%= value %&gt;
          &lt;/span&gt;
        &lt;% end %&gt;
        &lt;% reset_cycle(&quot;colors&quot;) %&gt;
      &lt;/td&gt;
   &lt;/tr&gt;
 &lt;% end %&gt;
</pre>
        </div>
      </div>

      <div id="method-M000552" class="method-detail">
        <a name="M000552"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000552.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000552.html');return false;">
          <span class="method-name">excerpt</span><span class="method-args">(text, phrase, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Extracts an <a href="TextHelper.html#M000552">excerpt</a> from
<tt>text</tt> that matches the first instance of <tt>phrase</tt>. The
<tt>:radius</tt> option expands the <a
href="TextHelper.html#M000552">excerpt</a> on each side of the first
occurrence of <tt>phrase</tt> by the number of characters defined in
<tt>:radius</tt> (which defaults to 100). If the <a
href="TextHelper.html#M000552">excerpt</a> radius overflows the beginning
or end of the <tt>text</tt>, then the <tt>:omission</tt> option (which
defaults to &quot;&#8230;&quot;) will be prepended/appended accordingly.
The resulting string will be stripped in any case. If the <tt>phrase</tt>
isn&#8216;t found, nil is returned.
</p>
<h4>Examples</h4>
<pre>
  excerpt('This is an example', 'an', :radius =&gt; 5)
  # =&gt; ...s is an exam...

  excerpt('This is an example', 'is', :radius =&gt; 5)
  # =&gt; This is a...

  excerpt('This is an example', 'is')
  # =&gt; This is an example

  excerpt('This next thing is an example', 'ex', :radius =&gt; 2)
  # =&gt; ...next...

  excerpt('This is also an example', 'an', :radius =&gt; 8, :omission =&gt; '&lt;chop&gt; ')
  # =&gt; &lt;chop&gt; is also an example
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M000552">excerpt</a></tt>
with the old API that accepts the <tt>radius</tt> as its optional third and
the <tt>ellipsis</tt> as its optional forth parameter:
</p>
<pre>
  excerpt('This is an example', 'an', 5)                   # =&gt; ...s is an exam...
  excerpt('This is also an example', 'an', 8, '&lt;chop&gt; ')   # =&gt; &lt;chop&gt; is also an example
</pre>
        </div>
      </div>

      <div id="method-M000551" class="method-detail">
        <a name="M000551"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000551.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000551.html');return false;">
          <span class="method-name">highlight</span><span class="method-args">(text, phrases, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Highlights one or more <tt>phrases</tt> everywhere in <tt>text</tt> by
inserting it into a <tt>:highlighter</tt> string. The highlighter can be
specialized by passing <tt>:highlighter</tt> as a single-quoted string with
\1 where the phrase is to be inserted (defaults to &#8217;&lt;strong
class=&quot;<a
href="TextHelper.html#M000551">highlight</a>&quot;&gt;\1&lt;/strong&gt;&#8217;)
</p>
<h4>Examples</h4>
<pre>
  highlight('You searched for: rails', 'rails')
  # =&gt; You searched for: &lt;strong class=&quot;highlight&quot;&gt;rails&lt;/strong&gt;

  highlight('You searched for: ruby, rails, dhh', 'actionpack')
  # =&gt; You searched for: ruby, rails, dhh

  highlight('You searched for: rails', ['for', 'rails'], :highlighter =&gt; '&lt;em&gt;\1&lt;/em&gt;')
  # =&gt; You searched &lt;em&gt;for&lt;/em&gt;: &lt;em&gt;rails&lt;/em&gt;

  highlight('You searched for: rails', 'rails', :highlighter =&gt; '&lt;a href=&quot;search?q=\1&quot;&gt;\1&lt;/a&gt;')
  # =&gt; You searched for: &lt;a href=&quot;search?q=rails&quot;&gt;rails&lt;/a&gt;
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M000551">highlight</a></tt>
with the old API that accepts the <tt>highlighter</tt> as its optional
third parameter:
</p>
<pre>
  highlight('You searched for: rails', 'rails', '&lt;a href=&quot;search?q=\1&quot;&gt;\1&lt;/a&gt;')     # =&gt; You searched for: &lt;a href=&quot;search?q=rails&quot;&gt;rails&lt;/a&gt;
</pre>
        </div>
      </div>

      <div id="method-M000557" class="method-detail">
        <a name="M000557"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000557.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000557.html');return false;">
          <span class="method-name">markdown</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the Markdown codes turned into HTML tags.
<em>This method requires <a
href="http://www.deveiate.org/projects/BlueCloth">BlueCloth</a> or another
Markdown library to be installed.</em>.
</p>
<h4>Examples</h4>
<pre>
  markdown(&quot;We are using __Markdown__ now!&quot;)
  # =&gt; &quot;&lt;p&gt;We are using &lt;strong&gt;Markdown&lt;/strong&gt; now!&lt;/p&gt;&quot;

  markdown(&quot;We like to _write_ `code`, not just _read_ it!&quot;)
  # =&gt; &quot;&lt;p&gt;We like to &lt;em&gt;write&lt;/em&gt; &lt;code&gt;code&lt;/code&gt;, not just &lt;em&gt;read&lt;/em&gt; it!&lt;/p&gt;&quot;

  markdown(&quot;The [Markdown website](http://daringfireball.net/projects/markdown/) has more information.&quot;)
  # =&gt; &quot;&lt;p&gt;The &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown website&lt;/a&gt;
  #     has more information.&lt;/p&gt;&quot;

  markdown('![The ROR logo](http://rubyonrails.com/images/rails.png &quot;Ruby on Rails&quot;)')
  # =&gt; '&lt;p&gt;&lt;img src=&quot;http://rubyonrails.com/images/rails.png&quot; alt=&quot;The ROR logo&quot; title=&quot;Ruby on Rails&quot; /&gt;&lt;/p&gt;'
</pre>
        </div>
      </div>

      <div id="method-M000553" class="method-detail">
        <a name="M000553"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000553.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000553.html');return false;">
          <span class="method-name">pluralize</span><span class="method-args">(count, singular, plural = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Attempts to <a href="TextHelper.html#M000553">pluralize</a> the
<tt>singular</tt> word unless <tt>count</tt> is 1. If <tt>plural</tt> is
supplied, it will use that when count is &gt; 1, otherwise it will use the
Inflector to determine the plural form
</p>
<h4>Examples</h4>
<pre>
  pluralize(1, 'person')
  # =&gt; 1 person

  pluralize(2, 'person')
  # =&gt; 2 people

  pluralize(3, 'person', 'users')
  # =&gt; 3 users

  pluralize(0, 'person')
  # =&gt; 0 people
</pre>
        </div>
      </div>

      <div id="method-M000562" class="method-detail">
        <a name="M000562"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000562.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000562.html');return false;">
          <span class="method-name">reset_cycle</span><span class="method-args">(name = &quot;default&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Resets a <a href="TextHelper.html#M000560">cycle</a> so that it starts from
the first element the next time it is called. Pass in <tt>name</tt> to
reset a named <a href="TextHelper.html#M000560">cycle</a>.
</p>
<h4>Example</h4>
<pre>
  # Alternate CSS classes for even and odd numbers...
  @items = [[1,2,3,4], [5,6,3], [3,4,5,6,7,4]]
  &lt;table&gt;
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;) -%&gt;&quot;&gt;
        &lt;% item.each do |value| %&gt;
          &lt;span style=&quot;color:&lt;%= cycle(&quot;#333&quot;, &quot;#666&quot;, &quot;#999&quot;, :name =&gt; &quot;colors&quot;) -%&gt;&quot;&gt;
            &lt;%= value %&gt;
          &lt;/span&gt;
        &lt;% end %&gt;

        &lt;% reset_cycle(&quot;colors&quot;) %&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;
</pre>
        </div>
      </div>

      <div id="method-M000558" class="method-detail">
        <a name="M000558"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000558.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000558.html');return false;">
          <span class="method-name">simple_format</span><span class="method-args">(text, html_options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns <tt>text</tt> transformed into HTML using simple formatting rules.
Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
paragraph and wrapped in <tt>&lt;p&gt;</tt> tags. One newline (<tt>\n</tt>)
is considered as a linebreak and a <tt>&lt;br /&gt;</tt> tag is appended.
This method does not remove the newlines from the <tt>text</tt>.
</p>
<p>
You can pass any HTML attributes into <tt>html_options</tt>. These will be
added to all created paragraphs.
</p>
<h4>Examples</h4>
<pre>
  my_text = &quot;Here is some basic text...\n...with a line break.&quot;

  simple_format(my_text)
  # =&gt; &quot;&lt;p&gt;Here is some basic text...\n&lt;br /&gt;...with a line break.&lt;/p&gt;&quot;

  more_text = &quot;We want to put a paragraph...\n\n...right there.&quot;

  simple_format(more_text)
  # =&gt; &quot;&lt;p&gt;We want to put a paragraph...&lt;/p&gt;\n\n&lt;p&gt;...right there.&lt;/p&gt;&quot;

  simple_format(&quot;Look ma! A class!&quot;, :class =&gt; 'description')
  # =&gt; &quot;&lt;p class='description'&gt;Look ma! A class!&lt;/p&gt;&quot;
</pre>
        </div>
      </div>

      <div id="method-M000555" class="method-detail">
        <a name="M000555"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000555.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000555.html');return false;">
          <span class="method-name">textilize</span><span class="method-args">(text, *options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the <a
href="http://www.textism.com/tools/textile">Textile</a> codes turned into
HTML tags.
</p>
<p>
You can learn more about Textile&#8216;s syntax at its <a
href="http://www.textism.com/tools/textile">website</a>. <em>This method is
only available if <a
href="http://whytheluckystiff.net/ruby/redcloth/">RedCloth</a> is
available</em>.
</p>
<h4>Examples</h4>
<pre>
  textilize(&quot;*This is Textile!*  Rejoice!&quot;)
  # =&gt; &quot;&lt;p&gt;&lt;strong&gt;This is Textile!&lt;/strong&gt;  Rejoice!&lt;/p&gt;&quot;

  textilize(&quot;I _love_ ROR(Ruby on Rails)!&quot;)
  # =&gt; &quot;&lt;p&gt;I &lt;em&gt;love&lt;/em&gt; &lt;acronym title=&quot;Ruby on Rails&quot;&gt;ROR&lt;/acronym&gt;!&lt;/p&gt;&quot;

  textilize(&quot;h2. Textile makes markup -easy- simple!&quot;)
  # =&gt; &quot;&lt;h2&gt;Textile makes markup &lt;del&gt;easy&lt;/del&gt; simple!&lt;/h2&gt;&quot;

  textilize(&quot;Visit the Rails website &quot;here&quot;:http://www.rubyonrails.org/.)
  # =&gt; &quot;&lt;p&gt;Visit the Rails website &lt;a href=&quot;http://www.rubyonrails.org/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&quot;

  textilize(&quot;This is worded &lt;strong&gt;strongly&lt;/strong&gt;&quot;)
  # =&gt; &quot;&lt;p&gt;This is worded &lt;strong&gt;strongly&lt;/strong&gt;&lt;/p&gt;&quot;

  textilize(&quot;This is worded &lt;strong&gt;strongly&lt;/strong&gt;&quot;, :filter_html)
  # =&gt; &quot;&lt;p&gt;This is worded &amp;lt;strong&amp;gt;strongly&amp;lt;/strong&amp;gt;&lt;/p&gt;&quot;
</pre>
        </div>
      </div>

      <div id="method-M000556" class="method-detail">
        <a name="M000556"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000556.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000556.html');return false;">
          <span class="method-name">textilize_without_paragraph</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the Textile codes turned into HTML tags, but
without the bounding &lt;p&gt; tag that RedCloth adds.
</p>
<p>
You can learn more about Textile&#8216;s syntax at its <a
href="http://www.textism.com/tools/textile">website</a>. <em>This method is
requires <a href="http://whytheluckystiff.net/ruby/redcloth/">RedCloth</a>
to be available</em>.
</p>
<h4>Examples</h4>
<pre>
  textilize_without_paragraph(&quot;*This is Textile!*  Rejoice!&quot;)
  # =&gt; &quot;&lt;strong&gt;This is Textile!&lt;/strong&gt;  Rejoice!&quot;

  textilize_without_paragraph(&quot;I _love_ ROR(Ruby on Rails)!&quot;)
  # =&gt; &quot;I &lt;em&gt;love&lt;/em&gt; &lt;acronym title=&quot;Ruby on Rails&quot;&gt;ROR&lt;/acronym&gt;!&quot;

  textilize_without_paragraph(&quot;h2. Textile makes markup -easy- simple!&quot;)
  # =&gt; &quot;&lt;h2&gt;Textile makes markup &lt;del&gt;easy&lt;/del&gt; simple!&lt;/h2&gt;&quot;

  textilize_without_paragraph(&quot;Visit the Rails website &quot;here&quot;:http://www.rubyonrails.org/.)
  # =&gt; &quot;Visit the Rails website &lt;a href=&quot;http://www.rubyonrails.org/&quot;&gt;here&lt;/a&gt;.&quot;
</pre>
        </div>
      </div>

      <div id="method-M000550" class="method-detail">
        <a name="M000550"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000550.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000550.html');return false;">
          <span class="method-name">truncate</span><span class="method-args">(text, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Truncates a given <tt>text</tt> after a given <tt>:length</tt> if
<tt>text</tt> is longer than <tt>:length</tt> (defaults to 30). The last
characters will be replaced with the <tt>:omission</tt> (defaults to
&quot;&#8230;&quot;) for a total length not exceeding <tt>:length</tt>.
</p>
<h4>Examples</h4>
<pre>
  truncate(&quot;Once upon a time in a world far far away&quot;)
  # =&gt; Once upon a time in a world...

  truncate(&quot;Once upon a time in a world far far away&quot;, :length =&gt; 14)
  # =&gt; Once upon a...

  truncate(&quot;And they found that many people were sleeping better.&quot;, :length =&gt; 25, &quot;(clipped)&quot;)
  # =&gt; And they found t(clipped)

  truncate(&quot;And they found that many people were sleeping better.&quot;, :omission =&gt; &quot;... (continued)&quot;, :length =&gt; 25)
  # =&gt; And they f... (continued)
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M000550">truncate</a></tt>
with the old API that accepts the <tt>length</tt> as its optional second
and the <tt>ellipsis</tt> as its optional third parameter:
</p>
<pre>
  truncate(&quot;Once upon a time in a world far far away&quot;, 14)
  # =&gt; Once upon a...

  truncate(&quot;And they found that many people were sleeping better.&quot;, 25, &quot;... (continued)&quot;)
  # =&gt; And they f... (continued)
</pre>
        </div>
      </div>

      <div id="method-M000554" class="method-detail">
        <a name="M000554"></a>

        <div class="method-heading">
          <a href="TextHelper.src/M000554.html" target="Code" class="method-signature"
            onclick="popupCode('TextHelper.src/M000554.html');return false;">
          <span class="method-name">word_wrap</span><span class="method-args">(text, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wraps the <tt>text</tt> into lines no longer than <tt>line_width</tt>
width. This method breaks on the first whitespace character that does not
exceed <tt>line_width</tt> (which is 80 by default).
</p>
<h4>Examples</h4>
<pre>
  word_wrap('Once upon a time')
  # =&gt; 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...')
  # =&gt; Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding\n a successor to the throne turned out to be more trouble than anyone could have\n imagined...

  word_wrap('Once upon a time', :line_width =&gt; 8)
  # =&gt; Once upon\na time

  word_wrap('Once upon a time', :line_width =&gt; 1)
  # =&gt; Once\nupon\na\ntime
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M000554">word_wrap</a></tt>
with the old API that accepts the <tt>line_width</tt> as its optional
second parameter:
</p>
<pre>
  word_wrap('Once upon a time', 8)     # =&gt; Once upon\na time
</pre>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>