Module: TinyMCE::Rails::Helper

Defined in:
lib/tinymce/rails/helper.rb

Instance Method Summary collapse

Instance Method Details

#tinymce(options = {}) ⇒ Object

Initializes TinyMCE on the current page based on the global configuration.

Custom options can be set via the options hash, which will be passed to the TinyMCE init function.

By default, all textareas with a class of “tinymce” will have the TinyMCE editor applied. The current locale will also be used as the language when TinyMCE language files are available, falling back to English if not available. The :editor_selector and :language options can be used to override these defaults.

Examples:

<%= tinymce(:theme => "advanced", :editor_selector => "editorClass") %>


16
17
18
# File 'lib/tinymce/rails/helper.rb', line 16

def tinymce(options={})
  javascript_tag { tinymce_javascript(options) }
end

#tinymce_assetsObject

Includes TinyMCE javascript assets via a script tag.



27
28
29
# File 'lib/tinymce/rails/helper.rb', line 27

def tinymce_assets
  javascript_include_tag "tinymce"
end

#tinymce_javascript(options = {}) ⇒ Object

Returns the JavaScript code required to initialize TinyMCE.



21
22
23
24
# File 'lib/tinymce/rails/helper.rb', line 21

def tinymce_javascript(options={})
  configuration = TinyMCE::Rails.configuration.merge(options)
  "tinyMCE.init(#{configuration.options_for_tinymce.to_json});".html_safe
end