lib/framework/rho/render.rb in rhodes-3.4.2 vs lib/framework/rho/render.rb in rhodes-3.5.1.12
- old
+ new
@@ -54,11 +54,16 @@
def self.renderfile(filename, req = {}, res = {})
begin
res = ""
if filename.end_with?(RHO_ERB_EXT)
- res = (RhoController.new).inst_render_index(filename, req, res)
+ if RhoApplication::current_controller()
+ puts "reuse current action controller."
+ res = RhoApplication::current_controller().inst_render_index(filename, req, res)
+ else
+ res = (RhoController.new).inst_render_index(filename, req, res)
+ end
else
res = IO.read(filename)
end
RhoController.start_objectnotify()
RhoController.start_geoview_notification()
@@ -88,13 +93,14 @@
@content = eval_compiled_file(filename, getBinding() )
if !xhr?
rho_info 'index layout'
layout = File.dirname(filename) + "/layout" + RHO_ERB_EXT
@content = eval_compiled_file(layout, getBinding() ) if Rho::file_exist?(layout)
- else
+ else
if @request["headers"]["Transition-Enabled"] == "true"
- @content = "<div>#{@content}</div>"
+ #puts "add 'div' in inst_render_index"
+ @content = "<div>#{@content}</div>"
end
end
@content
end
@@ -178,10 +184,15 @@
end
#rho_info 'render content: ' + @content.length.to_s
if xhr? and options[:use_layout_on_ajax] != true
options[:layout] = false
if options[:partial].nil? && @request["headers"]["Transition-Enabled"] == "true"
- @content = "<div>#{@content}</div>"
+ #puts "add 'div' in render"
+ if !(@request["headers"]["Accept"] =~ /^\*\/\*/ || @request["headers"]["Accept"] =~ /^text\/html/)
+ @response["headers"]["Content-Type"] = @request["headers"]["Accept"].gsub(/\,.*/, '')
+ else
+ @content = "<div>#{@content}</div>"
+ end
end
elsif options[:layout].nil? or options[:layout] == true
options[:layout] = self.class.get_layout_name
end