New Plugin - Text Formatter
TextFormatter plugin allows you filter user input, use the syntax gem, before it is saved to the database.
Install the plugin:
ruby script\plugin install http://svn.railslodge.com/svn/plugins/text_formatter/
Install the following gems:
gem install htmltokenizer gem install syntax gem install hpricot
If you are using the syntax highlighting method, copy the css from /vender/plugins/text_formatter/stylesheets/text_formatter.css into your css file.
The following methods can be used in your models:
===Remove HTML Tags
Remove all html tags from the given fields
tf_remove_html_tags :fieldname #e.g. tf_remove_html_tags :title, :post
===Escape HTML Characters
Escape all tags and special characters
tf_escape_html_characters :fieldname #e.g. tf_escape_all_html_characters :title, :post
===Escape Only Text Characters
Escape all text except html tags
tf_escape_text_characters :fieldname #e.g. tf_escape_text_characters :title, :post
===Syntax Highlighting
Add syntax highlighting to all text within pre tags
tf_syntax_highlighting :fieldname #e.g. tf_syntax_highlighting :title, :post
===Simple Text Markup
Apply SimpleTextMarkup
tf_simple_text_markup :fieldname #e.g. tf_simple_text_markup :title, :post
===Content Formatter
Remove all html tags, SimpleTextMarkup, encode tags within html tags, syntax highlighting
tf_content_formatter :fieldname #e.g. tf_content_formatter :title, :post
===Basic Formatter
Remove all html tags, SimpleTextMarkup, encode tags within html tags
tf_basic_formatter :fieldname #e.g. tf_basic_formatter :title, :post


thank you.
Please log in to leave a comment