Module: RailsEmbedEditor::ApplicationHelper

Defined in:
app/helpers/rails_embed_editor/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#rails_embed_editor(filename, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/rails_embed_editor/application_helper.rb', line 3

def rails_embed_editor(filename, options ={})
  options[:editormode] ||= RailsEmbedEditor::EditorMode::READ_ONLY
  manager = RailsEmbedEditor::FileManager.from_options(filename, options)
  text = manager.read_text.chomp
  first_line = manager.first_line
  last_line = manager.last_line
  ('div', text, :class => 'rails_embed_code_editor',
              'data-first-line' => first_line, 'data-last-line' => last_line, 'data-filename' => filename,
              'data-highlight' => options[:highlight],
              'data-editormode' => options[:editormode])
end