public
Description: The invisible framework
Homepage: http://macournoyer.com/
Clone URL: git://github.com/macournoyer/invisible.git
Add support for named views
macournoyer (author)
Mon Jul 21 13:20:24 -0700 2008
commit  e3c0077864dd692f6a57146a80a6a371934e1dc3
tree    1ecc05206d49cbc6a6dfe0cc46dd47753ca7383e
parent  de7385e0553bade97d2c7fcf2e9d8ee2ae693a2e
...
43
44
45
 
46
47
48
...
67
68
69
70
 
 
 
 
 
71
72
73
...
81
82
83
 
 
 
 
84
85
86
...
43
44
45
46
47
48
49
...
68
69
70
 
71
72
73
74
75
76
77
78
...
86
87
88
89
90
91
92
93
94
95
0
@@ -43,6 +43,7 @@ class Invisible
0
   def initialize(&block)
0
     @actions = []
0
     @layouts = {}
0
+ @views = {}
0
     @helpers = Module.new
0
     @app = self
0
     instance_eval(&block) if block
0
@@ -67,7 +68,11 @@ class Invisible
0
     options = args.last.is_a?(Hash) ? args.pop : {}
0
     layout = @layouts[options.delete(:layout) || :default]
0
     assigns = { :request => request, :params => params, :session => session }
0
- content = block ? Markaby::Builder.new(assigns, @helpers, &block).to_s : args.last
0
+ content = case args.last
0
+ when String then args.last
0
+ when Symbol then Markaby::Builder.new(assigns, @helpers, &@views[args.last]).to_s
0
+ when NilClass then Markaby::Builder.new(assigns, @helpers, &block).to_s
0
+ end
0
     content = Markaby::Builder.new(assigns.merge(:content => content), @helpers, &layout).to_s if layout
0
     [status, options, content]
0
   end
0
@@ -81,6 +86,10 @@ class Invisible
0
     instance_eval(&block)
0
   end
0
   
0
+ def view(name, &block)
0
+ @views[name] = block
0
+ end
0
+
0
   def call(env)
0
     @request = Rack::Request.new(env)
0
     @params = @request.params

Comments

    No one has commented yet.