aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/action_text/tag_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-10-02 17:30:22 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-10-02 17:30:22 -0700
commit1663bfad247732aa928e60489d4d394e338d1c49 (patch)
tree103f816fae59abf46f3a300ab34e3b1815ec97f3 /app/helpers/action_text/tag_helper.rb
parent283023f826165153d23d2373e1e023f873a46b41 (diff)
downloadrails-1663bfad247732aa928e60489d4d394e338d1c49.tar.gz
rails-1663bfad247732aa928e60489d4d394e338d1c49.tar.bz2
rails-1663bfad247732aa928e60489d4d394e338d1c49.zip
Add a bit more documentation
Diffstat (limited to 'app/helpers/action_text/tag_helper.rb')
-rw-r--r--app/helpers/action_text/tag_helper.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/helpers/action_text/tag_helper.rb b/app/helpers/action_text/tag_helper.rb
index 28c62166dd..8d1ff0aaad 100644
--- a/app/helpers/action_text/tag_helper.rb
+++ b/app/helpers/action_text/tag_helper.rb
@@ -2,6 +2,17 @@ module ActionText
module TagHelper
cattr_accessor(:id, instance_accessor: false) { 0 }
+ # Returns a `trix-editor` tag that instantiates the Trix JavaScript editor as well as a hidden field
+ # that Trix will write to on changes, so the content will be sent on form submissions.
+ #
+ # ==== Options
+ # * <tt>:class</tt> - Defaults to "trix-content" which ensures default styling is applied.
+ #
+ # ==== Example
+ #
+ # rich_text_area_tag "content", message.content
+ # # <input type="hidden" name="content" id="trix_input_post_1">
+ # # <trix-editor id="content" input="trix_input_post_1" class="trix-content" ...></trix-editor>
def rich_text_area_tag(name, value = nil, options = {})
options = options.symbolize_keys
@@ -37,6 +48,18 @@ module ActionView::Helpers
end
module FormHelper
+ # Returns a `trix-editor` tag that instantiates the Trix JavaScript editor as well as a hidden field
+ # that Trix will write to on changes, so the content will be sent on form submissions.
+ #
+ # ==== Options
+ # * <tt>:class</tt> - Defaults to "trix-content" which ensures default styling is applied.
+ #
+ # ==== Example
+ # form_with(model: @message) do |form|
+ # form.rich_text_area :content
+ # end
+ # # <input type="hidden" name="message[content]" id="message_content_trix_input_message_1">
+ # # <trix-editor id="content" input="message_content_trix_input_message_1" class="trix-content" ...></trix-editor>
def rich_text_area(object_name, method, options = {})
Tags::ActionText.new(object_name, method, self, options).render
end