Module: TrixEditorHelper

Included in:
ActionView::Helpers, ActionView::Helpers::Tags::TrixEditor
Defined in:
lib/trix/form.rb

Instance Method Summary collapse

Instance Method Details

#trix_editor_tag(name, value = nil, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/trix/form.rb', line 8

def trix_editor_tag(name, value = nil, options = {})
  options.symbolize_keys!

  css_class = Array.wrap(options.delete(:class)).join(' ')
  attributes = {
    class: "formatted_content trix-content #{css_class}".squish,
    input: "trix_input_#{TrixEditorHelper.id += 1}"
  }.merge(options)

  editor_tag = ('trix-editor', '', attributes)
  input_tag = hidden_field_tag(name, value, id: attributes[:input])

  input_tag + editor_tag
end