module Rack::ServerPages::CoreHelper
Public Instance Methods
halt(*args)
click to toggle source
# File lib/rack/server_pages.rb, line 296 def halt(*args) if args[0].is_a? Integer response.headers.merge! args[1] if (a1_is_h = args[1].is_a? Hash) response.body = [a1_is_h ? args[2] : args[1]] response.status = args[0] elsif args[0] response.body = [args[0]] end throw :halt end
layout(file = nil)
click to toggle source
# File lib/rack/server_pages.rb, line 291 def layout(file = nil) @layout = file unless file.nil? @layout end
partial(file, locals = {}, &block)
click to toggle source
# File lib/rack/server_pages.rb, line 283 def partial(file, locals = {}, &block) if (tpl_file = Dir["#{file}{.*,}"].first) && (template = Template[tpl_file]) template.render(self, locals, &block) else IO.read(file) end end
redirect(target, status = 302)
click to toggle source
# File lib/rack/server_pages.rb, line 278 def redirect(target, status = 302) response.redirect(target, status) halt end
url(path = '')
click to toggle source
# File lib/rack/server_pages.rb, line 307 def url(path = '') env['SCRIPT_NAME'] + (path.to_s[0, 1] != '/' ? '/' : '') + path.to_s end