module Roda::RodaPlugins::Render::InstanceMethods
def _optimized_render_method_for_locals(template, locals)
of the template render if the optimized path is used, or nil if the optimized
Use an optimized render path for templates with a hash of locals. Returns the result
def _optimized_render_method_for_locals(template, locals) return unless method_cache = render_opts[:template_method_cache] locals_keys = locals.keys.sort key = [:_render_locals, template, locals_keys] optimized_template = case template when String, Symbol _cached_template_method_lookup(method_cache, key) else return end case optimized_template when Symbol optimized_template else if method_cache_key = _cached_template_method_key(key) template_obj = retrieve_template(render_template_opts(template, NO_CACHE)) method_name = :"_roda_template_locals_#{self.class.object_id}_#{method_cache_key}" method_cache[method_cache_key] = case template_obj when Render::TemplateMtimeWrapper template_obj.define_compiled_method(self.class, method_name, locals_keys) else begin unbound_method = Render.tilt_template_compiled_method(template_obj, locals_keys, self.class) rescue ::NotImplementedError false else self.class::RodaCompiledTemplates.send(:define_method, method_name, unbound_method) self.class::RodaCompiledTemplates.send(:private, method_name) method_name end end end end end