class Ckeditor::TextArea

Attributes

ck_options[R]
options[R]
template[R]

Public Class Methods

new(template, options) click to toggle source
# File lib/ckeditor/text_area.rb, line 16
def initialize(template, options)
  @template = template
  @options = options.stringify_keys
  @ck_options = (@options.delete('ckeditor') || {}).stringify_keys
  @ck_options['customConfig'] ||= template.asset_path(Ckeditor.js_config_url) if Ckeditor.cdn_enabled?
end

Public Instance Methods

render_instance_tag(object_name, method) click to toggle source
# File lib/ckeditor/text_area.rb, line 23
def render_instance_tag(object_name, method)
  tag = build_tag(object_name, method)
  tag.send(:add_default_name_and_id, options) if options['id'].blank?

  render tag.respond_to?(:to_text_area_tag) ? tag.to_text_area_tag(options) : tag.render
end
render_tag(name, content) click to toggle source
# File lib/ckeditor/text_area.rb, line 30
def render_tag(name, content)
  options['id'] = sanitize_to_id(options['id'] || name)

  render text_area_tag(name, content, options)
end

Protected Instance Methods

build_tag(object_name, method) click to toggle source
# File lib/ckeditor/text_area.rb, line 48
def build_tag(object_name, method)
  if defined?(ActionView::Base::Tags::TextArea)
    ActionView::Base::Tags::TextArea.new(object_name, method, template, options.symbolize_keys)
  else
    ActionView::Base::InstanceTag.new(object_name, method, template, options.delete('object'))
  end
end
output_buffer() click to toggle source
# File lib/ckeditor/text_area.rb, line 44
def output_buffer
  @output_buffer ||= ActiveSupport::SafeBuffer.new
end
render(input) click to toggle source
# File lib/ckeditor/text_area.rb, line 38
def render(input)
  output_buffer << input
  output_buffer << javascript_tag(Utils.js_replace(options['id'], ck_options))
  output_buffer
end