module TrixEditorHelper

Public Instance Methods

trix_editor_tag(name, value = nil, options = {}) click to toggle source
# 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 = content_tag('trix-editor', '', attributes)
  input_tag = hidden_field_tag(name, value, id: attributes[:input])

  input_tag + editor_tag
end