0.01
No commit activity in last 3 years
No release in over 3 years
textile designed for advanced usage, like scheduling versions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 0
>= 0
>= 0
~> 2

Runtime

 Project Readme

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: 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 © 2010 Andre Pankratz. See LICENSE for details.