Class: Merb::BootLoader::Templates
- Inherits:
-
Merb::BootLoader
- Object
- Merb::BootLoader
- Merb::BootLoader::Templates
- Defined in:
- merb-core/lib/merb-core/bootloader.rb
Overview
Precompiles all non-partial templates.
Class Method Summary (collapse)
-
+ (Array<String>) run
Loads all non-partial templates into the Merb::InlineTemplates module.
-
+ (Array<String>) template_paths
private
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
+ (Array<String>) run
Loads all non-partial templates into the Merb::InlineTemplates module.
1055 1056 1057 1058 1059 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 1055 def run template_paths.each do |path| Merb::Template.inline_template(File.open(path)) end end |
+ (Array<String>) template_paths
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds a list of templates to load.
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 1067 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 |