class ActionFramework::Controller

Public Class Methods

new(env,req,res,url) click to toggle source
# File lib/actionframework/controller.rb, line 10
def initialize env,req,res,url
        @req = req
        @res = res
        @url = url
        @env = env
end
run_before(*args) click to toggle source
# File lib/actionframework/controller.rb, line 71
def self.run_before(*args)
        args.each do |methodname|
                        @@run_before << methodname
        end
end

Public Instance Methods

_erb(templatename,context=self) click to toggle source
# File lib/actionframework/controller.rb, line 96
def _erb templatename,context=self
        renderer = Tilt::ERBTemplate.new("./views/#{templatename}")
        renderer.render(context)
end
_render(filename) click to toggle source

Legacy support for partials

# File lib/actionframework/controller.rb, line 103
def _render filename
        File.read("./views/_/#{filename}.html")
end
_static(filename) click to toggle source
# File lib/actionframework/controller.rb, line 92
def _static filename
        File.read("./views/_/#{filename}.html")
end
env() click to toggle source
# File lib/actionframework/controller.rb, line 17
def env
        @env
end
erb(template) click to toggle source
# File lib/actionframework/controller.rb, line 37
def erb template
renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
output = renderer.render(self){ Tilt::ERBTemplate.new("views/"+template.to_s+".html.erb").render(self) }
return output
end
erb_text(erb_text) click to toggle source
# File lib/actionframework/controller.rb, line 43
def erb_text erb_text
        renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
output = renderer.render(self){ erb_text }
return output
end
error_erb(code) click to toggle source
# File lib/actionframework/controller.rb, line 49
def error_erb code
        if(Dir.exists? "views/errors")
                renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
       output = renderer.render(self){ Tilt::ERBTemplate.new("views/errors/#{code}.html.erb").render(self) }
       return output
else
        root = ActionFramework::Gem.root
        libdir = root.resources.to_s
        renderer = Tilt::ERBTemplate.new(libdir+"/views/errors/layout.html.erb")
       output = renderer.render(self){ Tilt::ERBTemplate.new(libdir+"/views/errors/#{code}.html.erb").render(self) }
end
end
execute_run_before() click to toggle source
# File lib/actionframework/controller.rb, line 77
def execute_run_before
        output = nil
        @@run_before.each do |methodname|
                returns = self.send(methodname)

                if(returns.class.to_s == "String")
                        output = returns
                        break
                end

        end

        return output
end
params() click to toggle source
# File lib/actionframework/controller.rb, line 29
def params
        @req.params
end
redirect(path) click to toggle source
# File lib/actionframework/controller.rb, line 66
def redirect path
        response.redirect path
        ""
end
request() click to toggle source
# File lib/actionframework/controller.rb, line 21
def request
        @req
end
response() click to toggle source
# File lib/actionframework/controller.rb, line 25
def response
        @res
end
session() click to toggle source
# File lib/actionframework/controller.rb, line 62
def session
        @req.session
end
url() click to toggle source
# File lib/actionframework/controller.rb, line 33
def url
        @url
end