Class: Merb::BootLoader::Templates
- Inherits:
-
Merb::BootLoader
- Object
- Merb::BootLoader
- Merb::BootLoader::Templates
- Defined in:
- lib/merb-core/bootloader.rb
Overview
Precompiles all non-partial templates.
Class Method Summary collapse
-
.run ⇒ Object
Loads all non-partial templates into the Merb::InlineTemplates module.
-
.template_paths ⇒ Object
Finds a list of templates to load.
Methods inherited from Merb::BootLoader
after, after_app_loads, before, before_app_loads, before_master_shutdown, before_worker_shutdown, default_framework, finished?, inherited, move_klass
Class Method Details
.run ⇒ Object
Loads all non-partial templates into the Merb::InlineTemplates module.
Returns
- Array
-
The list of template files which were loaded.
:api: plugin
1092 1093 1094 1095 1096 |
# File 'lib/merb-core/bootloader.rb', line 1092 def run template_paths.each do |path| Merb::Template.inline_template(File.open(path)) end end |
.template_paths ⇒ Object
Finds a list of templates to load.
Returns
- Array
-
All found template files whose basename does not begin with “_”.
:api: private
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 |
# File 'lib/merb-core/bootloader.rb', line 1104 def template_paths extension_glob = "{#{Merb::Template.template_extensions.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. controller_view_paths = [] Merb::AbstractController._abstract_subclasses.each do |klass| next if (const = Object.full_const_get(klass))._template_root.blank? controller_view_paths += const._template_roots.map { |pair| pair.first } end template_paths = controller_view_paths.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) # This ignores templates for partials, which need to be compiled at use time to generate # a preamble that assigns local variables template_paths.flatten.compact.uniq.grep(%r{^.*/[^_][^/]*$}) end |