Class: Merb::BootLoader::Templates

Inherits:
Merb::BootLoader show all
Defined in:
lib/merb-core/bootloader.rb

Class Method Summary collapse

Methods inherited from Merb::BootLoader

after, after_app_loads, before, before_app_loads, default_framework, inherited, move_klass

Class Method Details

.runObject

Loads the templates into the Merb::InlineTemplates module.



412
413
414
415
416
# File 'lib/merb-core/bootloader.rb', line 412

def run
  template_paths.each do |path|
    Merb::Template.inline_template(path)
  end
end

.template_pathsObject

Returns

Array

Template files found.



420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/merb-core/bootloader.rb', line 420

def template_paths
  extension_glob = "{#{Merb::Template::EXTENSIONS.keys.join(',')}}"

  # This gets all templates set in the controllers template roots        
  # We separate the two maps because most of controllers will have
  # the same _template_root, so it's silly to be globbing the same
  # path over and over.
  template_paths = Merb::AbstractController._abstract_subclasses.map do |klass| 
    Object.full_const_get(klass)._template_root
  end.uniq.compact.map {|path| Dir["#{path}/**/*.#{extension_glob}"] }

  # This gets the templates that might be created outside controllers
  # template roots.  eg app/views/shared/*
  template_paths << Dir["#{Merb.dir_for(:view)}/**/*.#{extension_glob}"] if Merb.dir_for(:view)

  template_paths.flatten.compact.uniq
end