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

public
Rubygem
Description: A lightweight and flexible website management system.
Homepage: http://webby.rubyforge.org/
Clone URL: git://github.com/TwP/webby.git
Modifying how partials are found -- no longer reverts to searching the 
whole
content folder for a partial. If it is not found, then an error is raised. 
The
user can also specify an absolution location for the partial (instead of 
the
directory of the current page being rendered).
Tim Pease (author)
Sat May 31 21:32:32 -0700 2008
commit  201dd1e10cdbee618556d8aa7f591234d0eaa210
tree    dc61bd2219520484529af3e9e88d6584c589205b
parent  483579ede9447880cf9ddb27f77d45a0b1714bf7
...
253
254
255
256
257
258
259
 
 
 
 
260
261
262
263
264
265
266
267
268
269
 
 
 
 
 
 
270
271
272
 
273
274
275
...
253
254
255
 
 
 
 
256
257
258
259
260
261
262
263
 
 
 
264
265
 
266
267
268
269
270
271
272
 
 
273
274
275
276
0
@@ -253,23 +253,24 @@ class Renderer
0
     end
0
   end
0
 
0
- # Attempts to locate a partial by name. The search starts in the directory
0
- # of the current page being rendered. If the partial is not found in the
0
- # current directory, the search starts again at the root of the content
0
- # folder.
0
+ # Attempts to locate a partial by name. If only the partial name is given,
0
+ # then the current directory of the page being rendered is searched for
0
+ # the partial. If a full path is given, then the partial is searched for
0
+ # in that directory.
0
   #
0
   # Raies a Webby::Error if the partial could not be found.
0
   #
0
   def _find_partial( part )
0
-
0
- # FIXME: this won't work for partial names with paths
0
-
0
     case part
0
     when String
0
- fn = '_' + part
0
+ part_dir = ::File.dirname(part)
0
+ part_dir = @page.dir if part_dir == '.'
0
+
0
+ part_fn = ::File.basename(part)
0
+ part_fn = '_' + part_fn unless part_fn =~ %r/^_/
0
+
0
       p = Resources.partials.find(
0
- :filename => fn, :in_directory => @page.dir ) rescue nil
0
- p ||= Resources.partials.find(:filename => fn)
0
+ :filename => part_fn, :in_directory => part_dir ) rescue nil
0
       raise ::Webby::Error, "could not find partial '#{part}'" if p.nil?
0
       p
0
     when ::Webby::Resources::Partial

Comments

    No one has commented yet.