Sha256: 8d566e80c145ebda3e8c3217c0582f4a5090e3e0824613ba13f99169a025e998

Contents?: true

Size: 1.87 KB

Versions: 6

Compression:

Stored size: 1.87 KB

Contents

= vidibus-textile

Basically, this is a wrapper for RedCloth with some extensions. It is inspired by the acts_as_textiled plugin and extends your Mongoid models.

This gem is part of the open source SOA framework Vidibus: http://vidibus.org


== Installation

Add the dependency to the Gemfile of your application:

  gem "vidibus-textile"

Then call `bundle install` on your console.


== Usage

The basic methods are:

  Vidibus::Textile.new('Some *say*, "love":http://doit.xxx is a _river_.').to_html
  # => '<p>Some <strong>say</strong>, <a href="http://doit.xxx">love</a> is a <em>river</em>.</p>'
  # (#to_html is provided by RedCloth)

  Vidibus::Textile.new('Some *say*, "love":http://doit.xxx is a _river_.').to_text
  # => "Some say, love is a river."

The method #to_text will return a plain text version of textile content but keep newlines intact. However, if
you just want a stripped version without newlines, provide the option :plain => true

  # #to_text with :plain => true
  Vidibus::Textile.new("Super\nTrouper").to_text(:plain => true)
  # => "Super Trouper"


== Mongoid integration

Adding textile content to your Mongoid model is simple:

  class Page
    include Mongoid::Document
    include Vidibus::Textile::Mongoid
    textile :body
  end

By setting textile :body on the page model above, it will be extended by two fields:

  field :body
  # => Contains the textile content.

  field :body_plain
  # => Contains a plain text version of the content, stored in the database.

Additionally, the method #body_html is available. As one could guess, it returns rendered html from the textile content.


== View helper

For your convenience, the view helper #stripped is available (as counterpart for Rails' #textilize).

  # In your view...
  stripped("*Super*\nTrouper", :plain => true)
  # => "Super Trouper"


== Copyright

Copyright (c) 2010 Andre Pankratz. See LICENSE for details.

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vidibus-textile-0.3.0 README.rdoc
vidibus-textile-0.2.4 README.rdoc
vidibus-textile-0.2.3 README.rdoc
vidibus-textile-0.2.2 README.rdoc
vidibus-textile-0.2.1 README.rdoc
vidibus-textile-0.2.0 README.rdoc