Module: MarchKindeditor::Helpers::KindeditorExt

Defined in:
lib/march_kindeditor/helpers/kindeditor_ext.rb

Instance Method Summary collapse

Instance Method Details

#kindeditor(name, method, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/march_kindeditor/helpers/kindeditor_ext.rb', line 13

def kindeditor(name, method, options = {})
  input_html = (options.delete(:input_html) || {})
  hash = input_html.stringify_keys
  instance_tag = ActionView::Base::InstanceTag.new(name, method, self, options.delete(:object))
  instance_tag.send(:add_default_name_and_id, hash)
  output_buffer = ActiveSupport::SafeBuffer.new
  output_buffer << instance_tag.to_text_area_tag(input_html)
  js = impl_kindeditor_js_replace(hash['id'], options)
  output_buffer << javascript_tag(js)
end

#kindeditor_tag(name, content = nil, options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/march_kindeditor/helpers/kindeditor_ext.rb', line 5

def kindeditor_tag(name, content = nil, options = {})
  id = sanitize_to_id(name)
  input_html = { :id => id }.merge(options.delete(:input_html) || {})
  output = ActiveSupport::SafeBuffer.new
  output << text_area_tag(name, content, input_html)
  output << javascript_tag(impl_kindeditor_js_replace(id, options))
end