Method: Webby::Renderer#_find_partial
- Defined in:
- lib/webby/renderer.rb
#_find_partial(part) ⇒ Object
Attempts to locate a partial by name. If only the partial name is given, then the current directory of the page being rendered is searched for the partial. If a full path is given, then the partial is searched for in that directory.
Raises a Webby::Error if the partial could not be found.
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/webby/renderer.rb', line 344 def _find_partial( part ) case part when String part_dir = ::File.dirname(part) part_dir = @page.dir if part_dir == '.' part_fn = ::File.basename(part) part_fn = '_' + part_fn unless part_fn =~ %r/^_/ p = Resources.partials.find( :filename => part_fn, :in_directory => part_dir ) rescue nil raise ::Webby::Error, "could not find partial '#{part}'" if p.nil? p when ::Webby::Resources::Partial part else raise ::Webby::Error, "expecting a partial or a partial name" end end |