public
Fork of wycats/merb-more
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/myobie/merb-more.git
Search Repo:
Added :template_roots option to controller_for_slice method
fabien (author)
Mon Jun 16 11:01:20 -0700 2008
commit  8c42a3590933e607756580b064ef533f2558b78b
tree    542905913f597c5aa34867f0c489e41f646471ea
parent  1d9252ad771323004d717a9aa6c6fbe6afaa89c2
...
46
47
48
 
 
49
50
51
...
46
47
48
49
50
51
52
53
0
@@ -46,6 +46,8 @@ module Merb
0
               self._template_roots << [self._template_root, :_slice_template_location]
0
               # app-level slices/<slice>/app/views for specific overrides
0
               self._template_roots << [join_template_path(slice_mod.app_dir_for(options[:templates_for]), options[:path]), :_slice_template_location]
0
+ # additional template roots for specific overrides (optional)
0
+ self._template_roots += Array(options[:template_roots]) if options[:template_roots]
0
             end
0
             # Set the layout for this slice controller
0
             layout_for_slice(options[:layout])
...
12
13
14
 
 
 
 
 
15
16
17
...
27
28
29
 
30
31
32
...
12
13
14
15
16
17
18
19
20
21
22
...
32
33
34
35
36
37
38
0
@@ -12,6 +12,11 @@ module Merb
0
       def [](module_name)
0
         Object.full_const_get(module_name.to_s) if exists?(module_name)
0
       end
0
+
0
+ # Helper method to transform a slice filename to a module Symbol
0
+ def filename2module(slice_file)
0
+ File.basename(slice_file, '.rb').gsub('-', '_').camel_case.to_sym
0
+ end
0
     
0
       # Register a Slice by its gem/lib path for loading at startup
0
       #
0
@@ -27,6 +32,7 @@ module Merb
0
       # @example Merb::Slices::register(__FILE__)
0
       # @example Merb::Slices::register('/path/to/my-slice/lib/my-slice.rb')
0
       def register(slice_file, force = true)
0
+ # do what filename2module does, but with intermediate variables
0
         identifier = File.basename(slice_file, '.rb')
0
         underscored = identifier.gsub('-', '_')
0
         module_name = underscored.camel_case

Comments

    No one has commented yet.