Sha256: 71506509ef617ee82b8784249813e91b3a8e921569d7b40b33b36bc0b87810ba
Contents?: true
Size: 1.07 KB
Versions: 13
Compression:
Stored size: 1.07 KB
Contents
# encoding: utf-8 # Rango::Mini is the most low-level part which can render # templates standalone. More low-level is only the RenderMixin. # See http://wiki.github.com/botanicus/rango/template-rendering require "rango/router" require "rango/mixins/render" require "rango/rack/request" module Rango module Mini include Rango::RenderMixin extend self # so you can run Rango::Mini.app def app(&block) raise ArgumentError, "Block is required" unless block_given? lambda do |env| Rango::Router.set_rack_env(env) request = Rango::Request.new(env) response = Rack::Response.new body = block.call(request, response) # TODO: check how rack test if object is stringable, probably not this way raise ArgumentError, "It has to return a valid rack body, #{body.inspect} returned" unless body.respond_to?(:each) || body.is_a?(String) response.write(body) array = response.finish [array[0], array[1], body] # we don't want to have Rack::Response instance instead body, it's mess! end end end end
Version data entries
13 entries across 13 versions & 1 rubygems