summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-04 09:57:53 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-04 09:57:53 +0100
commit824de119f25fe11077c42c22ab77dd1a6d579859 (patch)
tree6bb6c2d2facbd589af58888c83f17d8b171403f7
parentcd8ab4a588c70f726d255efbb61c535869920881 (diff)
downloadzorglub-824de119f25fe11077c42c22ab77dd1a6d579859.zip
zorglub-824de119f25fe11077c42c22ab77dd1a6d579859.tar.gz
Node: add Node#state and use it
-rw-r--r--lib/zorglub/node.rb10
-rw-r--r--spec/spec_helper.rb3
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb
index aed6376..5eb2b85 100644
--- a/lib/zorglub/node.rb
+++ b/lib/zorglub/node.rb
@@ -116,12 +116,13 @@ module Zorglub
#
def feed!
Node.call_before_hooks self
+ state :meth
@content = self.send @action[:method], *@action[:args]
e, v, l = Config.engine_proc(@action[:engine]), view, layout
# TODO compile and cache
- @action[:mode]=:view
+ state :view
@content = e.call v, self if e and File.exists? v
- @action[:mode]=:layout
+ state :layout
@content = e.call l, self if e and File.exists? l
Node.call_after_hooks self
@content
@@ -138,6 +139,11 @@ module Zorglub
"You are being redirected, please follow this link to: <a href='#{target}'>#{target}</a>!"
end
#
+ def state state=nil
+ @action[:state] = state unless state.nil?
+ @action[:state]
+ end
+ #
def engine engine=nil
@action[:engine] = engine unless engine.nil? or engine.empty?
@action[:engine]
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 96d224f..6509357 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -14,8 +14,7 @@ require 'zorglub'
#
HASH_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view,:args=>obj.args}.to_yaml }
RENDER_PROC = Proc.new { |path,obj|
- m = obj.action[:mode]
- case m
+ case obj.state
when :layout
"layout_start #{obj.content} layout_end"
when :view