Associate a set of possible editors/markup language processors with a field or fields on a model. A helper
is provided for displaying the proper editor or a plain textarea (for markup languages).
Gemfile
gem 'editable'
Rake:
rake editable_engine:install:migrations
rake db:migrate
Model:
class BlogPost < ActiveRecord::Base
acts_as_editable :body, :processor => :textile
end
View:
<%= form_for @post do |f| %>
...
<%= raw editor(@post, :body, {:cols => 60, :rows => 20}) %>
...
<% end %>
This is the field to attach the editor (and source processing)
This creates a text box and attaches any associated javascript necessary for the current editor type for that field.
This is an instance of ActiveRecord::Base that has acts_as_editable field(s)
This is the field the editor is for.
Options are turned into attributes on the created textarea
- Reverse – bare textarea, simple processor that reverses the string. used for the tests
- Textile – bare textarea, simple RedCloth processing of textile input.
- Need more tests
- Needs editor switching
- Needs more processors/editors integrated
- Needs better handling of multiple acts_as_editable fields, need to assign a processor to each field, rather than
keeping a single processor for the entire model. - We should be able to get a syntax aware textarea running for markdown/textile.
Submit other bugs, suggestions, feature requests, criticisms, kudos, etc to Issues