Class: Mack::Rendering::Engine::Rjs

Inherits:
Base
  • Object
show all
Defined in:
lib/mack-javascript/rendering/engine/rjs.rb

Overview

Allows use of the Builder::XmlMarkup engine to be used with rendering.

Defined Under Namespace

Modules: ViewTemplateHelpers

Instance Method Summary collapse

Instance Method Details

#extensionObject



21
22
23
# File 'lib/mack-javascript/rendering/engine/rjs.rb', line 21

def extension
  :rjs
end

#render(io, binding) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mack-javascript/rendering/engine/rjs.rb', line 7

def render(io, binding)
  if io.is_a?(File)
    io = io.read
  end
  @_jsp_page = Mack::JavaScript::ScriptGenerator.new(view_template.controller.session.id)
  view_template.instance_variable_set("@_jsp_page", @_jsp_page)
  eval(io, binding)
  resp = @_jsp_page.to_s
  if Mack.env == 'development'
    resp = "try {#{resp}}catch(e){alert('RJS error:\\n\\n' + e.toString());throw e};"
  end
  resp
end