diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-11 19:20:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-11 19:20:31 +0200 |
commit | b06ae981c92040fe06c0317f0d12dc3f02044d21 (patch) | |
tree | f1f541d55977be1f1e20e6e7bb10810a2863cf67 /lib | |
parent | cfe72087d3179c2e80f923f9061d9450714a1547 (diff) | |
download | zorglub-b06ae981c92040fe06c0317f0d12dc3f02044d21.zip zorglub-b06ae981c92040fe06c0317f0d12dc3f02044d21.tar.gz |
add Node#partial
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zorglub/node.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index a161cb6..6e0989f 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -32,7 +32,14 @@ module Zorglub meth||= 'index' node = self.new env, {:engine=>engine,:layout=>layout,:view=>r(meth),:method=>meth,:args=>args} return error_404 node if not node.respond_to? meth - node.realize + node.realize! + end + # + def partial meth, *args + node = self.new nil, {:engine=>engine,:layout=>'',:view=>r(meth),:method=>meth.to_s,:args=>args} + return error_404 node if not node.respond_to? meth + node.feed! + node.content end # def error_404 node @@ -45,7 +52,7 @@ module Zorglub # end # - attr_reader :action, :request, :response + attr_reader :action, :request, :response, :content # def initialize env, action @env = env @@ -54,19 +61,24 @@ module Zorglub @response = Rack::Response.new end # - def realize + def realize! catch(:stop_realize) { - @content = self.send @action[:method], *@action[:args] - e, v, l = Config.engine_proc(@action[:engine]), view, layout - # TODO compile and cache - @content = e.call v, self if e and File.exists? v - @content = e.call l, self if e and File.exists? l + feed! response.write @content response.finish response } end # + def feed! + @content = self.send @action[:method], *@action[:args] + e, v, l = Config.engine_proc(@action[:engine]), view, layout + # TODO compile and cache + @content = e.call v, self if e and File.exists? v + @content = e.call l, self if e and File.exists? l + @content + end + # def redirect target, options={}, &block status = options[:status] || 302 body = options[:body] || redirect_body(target) |