Class Merb::BootLoader::Templates
In: merb-core/lib/merb-core/bootloader.rb
Parent: Merb::BootLoader

Precompiles all non-partial templates.

Methods

Public Class methods

Loads all non-partial templates into the Merb::InlineTemplates module.

Returns

Array[String]:The list of template files which were loaded.

:api: plugin

[Source]

      # File merb-core/lib/merb-core/bootloader.rb, line 1094
1094:     def run
1095:       template_paths.each do |path|
1096:         Merb::Template.inline_template(File.open(path))
1097:       end
1098:     end

Finds a list of templates to load.

Returns

Array[String]:All found template files whose basename does not begin with "_".

:api: private

[Source]

      # File merb-core/lib/merb-core/bootloader.rb, line 1106
1106:     def template_paths
1107:       extension_glob = "{#{Merb::Template.template_extensions.join(',')}}"
1108: 
1109:       # This gets all templates set in the controllers template roots
1110:       # We separate the two maps because most of controllers will have
1111:       # the same _template_root, so it's silly to be globbing the same
1112:       # path over and over.
1113:       controller_view_paths = []
1114:       Merb::AbstractController._abstract_subclasses.each do |klass|
1115:         next if (const = Object.full_const_get(klass))._template_root.blank?
1116:         controller_view_paths += const._template_roots.map { |pair| pair.first }
1117:       end
1118:       template_paths = controller_view_paths.uniq.compact.map { |path| Dir["#{path}/**/*.#{extension_glob}"] }
1119: 
1120:       # This gets the templates that might be created outside controllers
1121:       # template roots.  eg app/views/shared/*
1122:       template_paths << Dir["#{Merb.dir_for(:view)}/**/*.#{extension_glob}"] if Merb.dir_for(:view)
1123: 
1124:       # This ignores templates for partials, which need to be compiled at use time to generate
1125:       # a preamble that assigns local variables
1126:       template_paths.flatten.compact.uniq.grep(%r{^.*/[^_][^/]*$})
1127:     end

[Validate]