class ActionView::Helpers::Tags::TrixEditor

Public Instance Methods

render() click to toggle source
# File lib/core_extensions/action_view/helpers/tags/trix_editor.rb, line 7
def render
  options = @options.stringify_keys
  add_default_name_and_id(options)
  options['input'] ||= generate_trix_unique_id
  name = options.delete('name')
  value = value_before_type_cast(object)
  options.symbolize_keys!

  attributes = { class: "formatted_content #{options[:class]}".squish }
  attributes[:autofocus] = true if options[:autofocus]
  attributes[:placeholder] = options[:placeholder]
  attributes[:input] = options.fetch(:input) { "trix_input" }

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

  editor_tag + input_tag
end

Private Instance Methods

generate_trix_unique_id() click to toggle source
# File lib/core_extensions/action_view/helpers/tags/trix_editor.rb, line 28
def generate_trix_unique_id
  tag_id + "_trix_input"
end