| 315 | | @@cached_template_extension[template_path] ||= |
|---|
| | 320 | if @@cache_template_extensions |
|---|
| | 321 | @@cached_template_extension[template_path] ||= find_template_extension_for(template_path) |
|---|
| | 322 | else |
|---|
| | 323 | find_template_extension_for(template_path) |
|---|
| | 324 | end |
|---|
| | 325 | end |
|---|
| | 326 | |
|---|
| | 327 | def delegate_template_exists?(template_path)#:nodoc: |
|---|
| | 328 | @@template_handlers.find { |k,| template_exists?(template_path, k) } |
|---|
| | 329 | end |
|---|
| | 330 | |
|---|
| | 331 | def erb_template_exists?(template_path)#:nodoc: |
|---|
| | 332 | template_exists?(template_path, :rhtml) |
|---|
| | 333 | end |
|---|
| | 334 | |
|---|
| | 335 | def builder_template_exists?(template_path)#:nodoc: |
|---|
| | 336 | template_exists?(template_path, :rxml) |
|---|
| | 337 | end |
|---|
| | 338 | |
|---|
| | 339 | def javascript_template_exists?(template_path)#:nodoc: |
|---|
| | 340 | template_exists?(template_path, :rjs) |
|---|
| | 341 | end |
|---|
| | 342 | |
|---|
| | 343 | def file_exists?(template_path)#:nodoc: |
|---|
| | 344 | template_file_name, template_file_extension = path_and_extension(template_path) |
|---|
| | 345 | |
|---|
| | 346 | if template_file_extension |
|---|
| | 347 | template_exists?(template_file_name, template_file_extension) |
|---|
| | 348 | else |
|---|
| | 349 | cached_template_extension(template_path) || |
|---|
| | 350 | %w(erb builder javascript delegate).any? do |template_type| |
|---|
| | 351 | send("#{template_type}_template_exists?", template_path) |
|---|
| | 352 | end |
|---|
| | 353 | end |
|---|
| | 354 | end |
|---|
| | 355 | |
|---|
| | 356 | # Returns true is the file may be rendered implicitly. |
|---|
| | 357 | def file_public?(template_path)#:nodoc: |
|---|
| | 358 | template_path.split('/').last[0,1] != '_' |
|---|
| | 359 | end |
|---|
| | 360 | |
|---|
| | 361 | private |
|---|
| | 362 | def full_template_path(template_path, extension) |
|---|
| | 363 | "#{@base_path}/#{template_path}.#{extension}" |
|---|
| | 364 | end |
|---|
| | 365 | |
|---|
| | 366 | def template_exists?(template_path, extension) |
|---|
| | 367 | file_path = full_template_path(template_path, extension) |
|---|
| | 368 | @@method_names.has_key?(file_path) || FileTest.exists?(file_path) |
|---|
| | 369 | end |
|---|
| | 370 | |
|---|
| | 371 | def path_and_extension(template_path) |
|---|
| | 372 | template_path_without_extension = template_path.sub(/\.(\w+)$/, '') |
|---|
| | 373 | [ template_path_without_extension, $1 ] |
|---|
| | 374 | end |
|---|
| | 375 | |
|---|
| | 376 | def cached_template_extension(template_path) |
|---|
| | 377 | @@cache_template_extensions && @@cached_template_extension[template_path] |
|---|
| | 378 | end |
|---|
| | 379 | |
|---|
| | 380 | def find_template_extension_for(template_path) |
|---|
| 324 | | end |
|---|
| 325 | | |
|---|
| 326 | | def delegate_template_exists?(template_path)#:nodoc: |
|---|
| 327 | | @@template_handlers.find { |k,| template_exists?(template_path, k) } |
|---|
| 328 | | end |
|---|
| 329 | | |
|---|
| 330 | | def erb_template_exists?(template_path)#:nodoc: |
|---|
| 331 | | template_exists?(template_path, :rhtml) |
|---|
| 332 | | end |
|---|
| 333 | | |
|---|
| 334 | | def builder_template_exists?(template_path)#:nodoc: |
|---|
| 335 | | template_exists?(template_path, :rxml) |
|---|
| 336 | | end |
|---|
| 337 | | |
|---|
| 338 | | def javascript_template_exists?(template_path)#:nodoc: |
|---|
| 339 | | template_exists?(template_path, :rjs) |
|---|
| 340 | | end |
|---|
| 341 | | |
|---|
| 342 | | def file_exists?(template_path)#:nodoc: |
|---|
| 343 | | template_file_name, template_file_extension = path_and_extension(template_path) |
|---|
| 344 | | |
|---|
| 345 | | if template_file_extension |
|---|
| 346 | | template_exists?(template_file_name, template_file_extension) |
|---|
| 347 | | else |
|---|
| 348 | | @@cached_template_extension[template_path] || |
|---|
| 349 | | %w(erb builder javascript delegate).any? do |template_type| |
|---|
| 350 | | send("#{template_type}_template_exists?", template_path) |
|---|
| 351 | | end |
|---|
| 352 | | end |
|---|
| 353 | | end |
|---|
| 354 | | |
|---|
| 355 | | # Returns true is the file may be rendered implicitly. |
|---|
| 356 | | def file_public?(template_path)#:nodoc: |
|---|
| 357 | | template_path.split('/').last[0,1] != '_' |
|---|
| 358 | | end |
|---|
| 359 | | |
|---|
| 360 | | private |
|---|
| 361 | | def full_template_path(template_path, extension) |
|---|
| 362 | | "#{@base_path}/#{template_path}.#{extension}" |
|---|
| 363 | | end |
|---|
| 364 | | |
|---|
| 365 | | def template_exists?(template_path, extension) |
|---|
| 366 | | file_path = full_template_path(template_path, extension) |
|---|
| 367 | | @@method_names.has_key?(file_path) || FileTest.exists?(file_path) |
|---|
| 368 | | end |
|---|
| 369 | | |
|---|
| 370 | | def path_and_extension(template_path) |
|---|
| 371 | | template_path_without_extension = template_path.sub(/\.(\w+)$/, '') |
|---|
| 372 | | [ template_path_without_extension, $1 ] |
|---|