Sha256: 37868056aff5e680634839ee6e45f6de7a8c06cd7cccb8f84007478ffe785160

Contents?: true

Size: 1.28 KB

Versions: 22

Compression:

Stored size: 1.28 KB

Contents

require 'rho/rhoapplication'

module Rho
  class RhoController

	def self.layout(name)
		@layout = name
	end

	def self.get_layout_name
		@layout.nil? ? 'layout' : @layout
	end

    def self.renderfile(filename)
      	if File.extname(filename) == '.iseq'
	    	render_index(filename)
	  	else
        	IO.read(filename)
		end
	end

	def self.render_index(filename)
		layout = File.dirname(filename) + "/layout_erb.iseq"
		@content = eval_compiled_file(filename, binding)
		@content = eval_compiled_file(layout, binding) if File.exist?(layout)
	    @content
	end

    def render(options = nil)
    	options = {} if options.nil? or !options.is_a?(Hash)
		options[:action] = :index if options[:action].nil?

		@content = eval_compiled_file(@request[:modelpath]+options[:action].to_s+'_erb.iseq', binding )

		if xhr? and options[:use_layout_on_ajax] != true
			options[:layout] = false
		elsif options[:layout].nil? or options[:layout] == true
			options[:layout] = self.class.get_layout_name
		end

		if options[:layout] != false
			layoutfile = RhoApplication::get_app_path(@request['application']) + options[:layout].to_s + "_erb.iseq"
			puts 'Layout file: ' + layoutfile
			@content = eval_compiled_file(layoutfile, binding ) if File.exist?(layoutfile)
		end

		@content
    end

  end # RhoController
end # Rho

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rhodes-framework-1.2.1 lib/rho/render.rb
rhodes-framework-1.2.0 lib/rho/render.rb
rhodes-0.2.1 lib/rho/render.rb
rhodes-0.2.4 lib/rho/render.rb
rhodes-0.2.3 lib/rho/render.rb
rhodes-0.2.2 lib/rho/render.rb
rhodes-0.2.5 lib/rho/render.rb
rhodes-0.2.6 lib/rho/render.rb
rhodes-0.3.0 lib/rho/render.rb
rhodes-framework-1.0.0 lib/rho/render.rb
rhodes-framework-1.0.1 lib/rho/render.rb
rhodes-framework-1.0.10 lib/rho/render.rb
rhodes-framework-1.0.2 lib/rho/render.rb
rhodes-framework-1.0.5 lib/rho/render.rb
rhodes-framework-1.0.4 lib/rho/render.rb
rhodes-framework-1.0.3 lib/rho/render.rb
rhodes-framework-1.0.7 lib/rho/render.rb
rhodes-framework-1.0.8 lib/rho/render.rb
rhodes-framework-1.0.6 lib/rho/render.rb
rhodes-framework-1.0.9 lib/rho/render.rb