class Markdaver::MarkdownEditorEnv
Attributes
root_path[R]
Public Class Methods
new( root_path: File.expand_path("../../../markdown-editor/"), script_file: nil, file_to_open: nil )
click to toggle source
# File lib/markdaver/markdown_editor_env.rb, line 5 def initialize( root_path: File.expand_path("../../../markdown-editor/"), script_file: nil, file_to_open: nil ) @root_path = root_path @script_file = script_file @file_to_open = file_to_open end
Public Instance Methods
index()
click to toggle source
# File lib/markdaver/markdown_editor_env.rb, line 15 def index @index ||= File.read(File.join @root_path, "index.html") .gsub(/<\/body>/, "\n<script>#{script}</script>\\0") end
Private Instance Methods
script()
click to toggle source
# File lib/markdaver/markdown_editor_env.rb, line 22 def script javascript_code = '' if @file_to_open and File.exist?(@file_to_open) javascript_code << %{ var openFile = `#{File.read(@file_to_open)}`; } end javascript_code + script_load end
script_load()
click to toggle source
# File lib/markdaver/markdown_editor_env.rb, line 30 def script_load (@script_file && File.read(@script_file)) || %{console.log("we need some script in the environment");} end