From 9afeb6e5a87e50eef1c87844e1c2923cc2680f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 16 Jun 2011 15:47:50 +0200 Subject: add Node#realize --- examples/sample.ru | 18 ++++-------------- lib/zorglub/node.rb | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/sample.ru b/examples/sample.ru index 48f59b0..b318f86 100644 --- a/examples/sample.ru +++ b/examples/sample.ru @@ -11,17 +11,11 @@ Zorglub::Config.root = File.dirname( File.absolute_path(__FILE__) ) class Node1 < Zorglub::Node # def index a1, *a2 - response.write "Node1:index" - response.write "

a1 : #{a1.inspect}

" - response.write "

a2 : #{a2.inspect}

" - response.write self.html - response.finish + "Node1:index

a1 : #{a1.inspect}

a2 : #{a2.inspect}

#{html}" end # def alt *args - response.write "Node1:alt" - response.write html - response.finish + "Node1:alt#{html}" end # end @@ -37,18 +31,14 @@ class Node2 < Zorglub::Node layout 'my-layout' # def index *args - response.write "Node2" - response.write html - response.finish + "Node2#{html}" end # def alt *args engine 'temp-engine' layout 'temp-layout-name' view 'path-to-temp-view' - response.write "Node2:alt" - response.write html - response.finish + "Node2:alt#{html}" end # end diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 89b0cf2..99d6c5d 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -31,8 +31,9 @@ module Zorglub meth||= 'index' node = self.new Rack::Request.new(env), Rack::Response.new, {:engine=>engine,:layout=>layout,:view=>File.join(r,meth),:method=>meth,:args=>args} return error_404 node if not node.respond_to? meth - # TODO session - node.send meth, *args + # TODO + # - session + node.realize end # def error_404 node @@ -53,6 +54,15 @@ module Zorglub @response = res end # + def realize + # TODO + # - use view + # - use layout + r = self.send @action[:method], *@action[:args] + response.write r + response.finish + end + # def engine engine=nil @action[:engine] = engine unless engine.nil? @action[:engine] -- cgit v1.1-2-g2b99