instance method textilize

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

textilize(text, *options)

Returns the text with all the Textile codes turned into HTML tags.

You can learn more about Textile’s syntax at its website. This method is only available if RedCloth is available.

Examples

textilize("*This is Textile!*  Rejoice!")
# => "<p><strong>This is Textile!</strong>  Rejoice!</p>"

textilize("I _love_ ROR(Ruby on Rails)!")
# => "<p>I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!</p>"

textilize("h2. Textile makes markup -easy- simple!")
# => "<h2>Textile makes markup <del>easy</del> simple!</h2>"

textilize("Visit the Rails website "here":http://www.rubyonrails.org/.)
# => "<p>Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>.</p>"

textilize("This is worded <strong>strongly</strong>")
# => "<p>This is worded <strong>strongly</strong></p>"

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

Parameters

text req
options rest
Source
# File actionpack/lib/action_view/helpers/text_helper.rb, line 245
      def textilize(text, *options)
        options ||= [:hard_breaks]

        if text.blank?
          ""
        else
          textilized = RedCloth.new(text, options)
          textilized.to_html
        end
      end

Defined in actionpack/lib/action_view/helpers/text_helper.rb line 245 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::TextHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close