GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Adds Template and BootLoader classes, and more:
* Automatically generates a render_foo method for new :foo mime types
* Started work on Render class
* Added new Template structure
* New Templating languages will only need to provide a mechanism for
  compiling templates into methods
wycats (author)
Sat Jan 12 18:15:52 -0800 2008
commit  266932186cdf84c39aac2000e31a709ad8074461
tree    4dc18b39ca81a7c60d644a7d978684e455f950cb
parent  248c2837aa42dc12b323dc6da15445ae3a774b6e
...
 
 
 
1
2
3
...
17
18
19
20
 
 
 
 
 
 
 
21
22
23
24
25
26
 
 
 
 
 
27
28
29
...
1
2
3
4
5
6
...
20
21
22
 
23
24
25
26
27
28
29
30
31
32
33
34
 
35
36
37
38
39
40
41
42
0
@@ -1,3 +1,6 @@
0
+#---
0
+# require 'merb' must happen after Merb::Config is instantiated
0
+
0
 require 'rubygems'
0
 require 'set'
0
 require 'fileutils'
0
@@ -17,13 +20,23 @@ module Merb
0
     # This is the core mechanism for setting up your application layout
0
     # merb-core won't set a default application layout, but merb-more will
0
     # use the app/:type layout that is in use in Merb 0.5
0
- def push_path(type, path, file_glob = "**/*.rb")
0
+ #
0
+ # ==== Parameters
0
+ # type<Symbol>:: The type of path being registered (i.e. :view)
0
+ # path<String>:: The full path
0
+ # file_glob<String>::
0
+ # A glob that will be used to autoload files under the path
0
+ def push_path(type, path, file_glob = "**/*.rb") enforce!(type => Symbol)
0
      load_paths[type] = [path, file_glob]
0
     end
0
     
0
     # Application paths
0
     def root() @root || Merb::Config[:merb_root] || Dir.pwd end
0
- def root=(value) @root ||= value end
0
+ # ==== Parameters
0
+ # value<String>:: the path to the root of the directory
0
+ def root=(value) @root = value end
0
+ # ==== Parameters
0
+ # path<String>:: the path to a directory under the root
0
     def root_path(path) File.join(root, path) end
0
     
0
     # Logger settings
...
11
12
13
 
14
15
...
11
12
13
14
15
16
0
@@ -11,4 +11,5 @@ module Merb
0
   autoload :Responder, "merb_core/controller/mixins/responder"
0
   autoload :Router, "merb_core/dispatch/router"
0
   autoload :SessionMixin, "merb_core/dispatch/session"
0
+ autoload :Template, "merb_core/controller/template"
0
 end
0
\ No newline at end of file
...
93
94
95
 
96
97
 
98
99
100
...
113
114
115
116
117
118
119
120
...
93
94
95
96
97
 
98
99
100
101
...
114
115
116
 
 
117
118
119
0
@@ -93,8 +93,9 @@ class Merb::Controller < AbstractController
0
     # Dispatch the action
0
     #
0
     # ==== Parameters
0
+ # action<~to_s>:: An action to dispatch to
0
     def dispatch(action=:index)
0
- start = Time.now
0
+ start = Time.now
0
       if self.class.callable_actions[action.to_s]
0
         params[:action] ||= action
0
         setup_session
0
@@ -113,7 +114,5 @@ class Merb::Controller < AbstractController
0
     def session() request.session end
0
     def route() request.route end
0
     
0
-
0
-
0
   end
0
 end
0
\ No newline at end of file
...
14
15
16
 
 
 
 
 
 
 
17
18
19
...
29
30
31
 
 
 
 
 
 
 
32
33
34
...
14
15
16
17
18
19
20
21
22
23
24
25
26
...
36
37
38
39
40
41
42
43
44
45
46
47
48
0
@@ -14,6 +14,13 @@ module Merb
0
     # calling :to_xml, or for the :js mime type, :to_json.
0
     # If there is no transform method, use nil.
0
     #
0
+ # ==== Autogenerated Methods
0
+ # Adding a mime-type adds a render_type method that sets the content
0
+ # type and calls render.
0
+ #
0
+ # By default this does: def render_all, def render_yaml, def render_text,
0
+ # def render_html, def render_xml, def render_js, and def render_yaml
0
+ #
0
     # ==== Parameters
0
     # key<Symbol>:: The name of the mime-type. This is used by the provides API
0
     # transform_method<~to_s?>::
0
@@ -29,6 +36,13 @@ module Merb
0
         {:request_headers => values,
0
          :transform_method => transform_method,
0
          :response_headers => new_response_headers })
0
+
0
+ Merb::RenderMixin.class_eval <<-EOS
0
+ def render_#{key}(thing = nil, opts = {})
0
+ content_type = :#{key}
0
+ render thing, opts
0
+ end
0
+ EOS
0
     end
0
 
0
     # Removes a MIME-type from the mime-type list
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -0,0 +1,24 @@
0
+module Merb::RenderMixin
0
+
0
+ # ==== Parameters
0
+ # base<Module>:: Module that is including RenderMixin (probably a controller)
0
+ def self.included(base)
0
+ base.class_eval do
0
+ class_inheritable_accessor :_layout, :_cached_templates
0
+ attr_accessor :template
0
+ end
0
+ end
0
+
0
+ def render(thing = nil, opts = {})
0
+ opts, thing = thing, nil if thing.is_a?(Hash)
0
+ thing ||= params[:action]
0
+
0
+ case thing
0
+ when Symbol
0
+
0
+ when String
0
+
0
+ end
0
+ end
0
+
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.