Redcloth Template plugin

Plugin details

This plugin registers a template handler for *.red files, which will be run through ERB and RedCloth, and enables you to use Textile and Markdown syntax directly in your views.

Websitehttp://snafu.diarrhea.ch/software/rails#redcloth_template Repositoryhttp://dev.diarrhea.ch/svn/rails_plugins/trunk/redcloth_template/ Author Markus Koller Tags RedCloth, template LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://dev.diarrhea.ch/svn/rails_plugins/trunk/redcloth_template/

Use the class method auto_convert to specify fields, and pass symbols for the helpers in the :with option:

class MyModel < ActiveRecord::Base
  auto_convert :name, :text, :with => :strip_tags
end


You can specify multiple helpers by passing an array. The helpers will be run in the order they’re specified in:

class MyModel < ActiveRecord::Base
  auto_convert :name, :text, :with => [ :strip_tags, :simple_format ]
end


For more complex cases, pass a block which will be given the value. The helpers are also available in the context of the block:

class MyModel < ActiveRecord::Base
  auto_convert :name, :text do |value|
    strip_tags(value).strip.gsub(/[^\w ]/, '')
  end
end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 10 months ago