module Ace::Helper::Builder
Public Instance Methods
ace(code_string, &block)
click to toggle source
The javascript that runs:
-
Audio client based on gibberish.js
-
Ace
editor with post code
# File lib/ace/helper.rb, line 14 def ace(code_string, &block) #string = hook_gac() string = hook_editor(MODE, THEME) string << hook_code(code_string) # FIX # When hook commands, the code do not appears on editor # string << hook_ace_commands(RENDER_OPTIONS[:commands]) string = CoffeeScript.compile(string, :bare => true) javascript_tag(string, :id => "ace-#{Time.now}") end
Protected Instance Methods
hook_ace_commands(commands, offset)
click to toggle source
# File lib/ace/helper.rb, line 41 def hook_ace_commands(commands, offset) src = "" commands.each{|k, v| src << "editor.commands.addCommand#{offset}" src << "name: '#{k}'#{offset}" v.each_pair{|kk, vv| src << "#{kk}: #{vv}#{offset}" } src << "readOnly: true\n" } src << "console.log 'commands added to editor!'\n" end
hook_code(code_string)
click to toggle source
# File lib/ace/helper.rb, line 35 def hook_code(code_string) s = "#{code_string}" string = "editor.setValue '#{escape_javascript(s)}'\n" string << "console.log 'code script embeeded to editor!'\n" end
hook_editor(mode, theme)
click to toggle source
# File lib/ace/helper.rb, line 28 def hook_editor(mode, theme) string = "window.editor = editor = ace.edit('#{mode}_editor')\n" string << "editor.setTheme 'ace/theme/#{theme}'\n" string << "editor.getSession().setMode 'ace/mode/#{mode}'\n" string << "console.log 'Ace editor loaded!: {mode: #{mode}, theme: #{theme} }'\n" end