lib/roda/plugins/render.rb in roda-3.59.0 vs lib/roda/plugins/render.rb in roda-3.60.0

- old
+ new

@@ -212,22 +212,22 @@ # Support for using compiled methods directly requires Ruby 2.3 for the # method binding to work, and Tilt 1.2 for Tilt::Template#compiled_method. tilt_compiled_method_support = defined?(Tilt::VERSION) && Tilt::VERSION >= '1.2' && ([1, -2].include?(((compiled_method_arity = Tilt::Template.instance_method(:compiled_method).arity) rescue false))) NO_CACHE = {:cache=>false}.freeze - COMPILED_METHOD_SUPPORT = RUBY_VERSION >= '2.3' && tilt_compiled_method_support + COMPILED_METHOD_SUPPORT = RUBY_VERSION >= '2.3' && tilt_compiled_method_support && ENV['RODA_RENDER_COMPILED_METHOD_SUPPORT'] != 'no' if compiled_method_arity == -2 def self.tilt_template_compiled_method(template, locals_keys, scope_class) template.send(:compiled_method, locals_keys, scope_class) end + # :nocov: else - # :nocov: def self.tilt_template_compiled_method(template, locals_keys, scope_class) template.send(:compiled_method, locals_keys) end - # :nocov: + # :nocov: end # Setup default rendering options. See Render for details. def self.configure(app, opts=OPTS) if app.opts[:render] @@ -364,13 +364,11 @@ end false end - # :nocov: if COMPILED_METHOD_SUPPORT - # :nocov: # Compile a method in the given module with the given name that will # call the compiled template method, updating the compiled template method def define_compiled_method(roda_class, method_name, locals_keys=EMPTY_ARRAY) mod = roda_class::RodaCompiledTemplates internal_method_name = :"_#{method_name}" @@ -410,13 +408,11 @@ end end end module ClassMethods - # :nocov: if COMPILED_METHOD_SUPPORT - # :nocov: # If using compiled methods and there is an optimized layout, speed up # access to the layout method to improve the performance of view. def freeze begin _freeze_layout_method @@ -435,13 +431,11 @@ # them as necessary to prevent changes in the subclass # affecting the parent class. def inherited(subclass) super opts = subclass.opts[:render] = subclass.opts[:render].dup - # :nocov: if COMPILED_METHOD_SUPPORT - # :nocov: opts[:template_method_cache] = (opts[:cache_class] || RodaCache).new end opts[:cache] = opts[:cache].dup opts.freeze end @@ -457,13 +451,11 @@ def _freeze_layout_method if render_opts[:layout] instance = allocate instance.send(:retrieve_template, instance.send(:view_layout_opts, OPTS)) - # :nocov: if COMPILED_METHOD_SUPPORT - # :nocov: if (layout_template = render_opts[:optimize_layout]) && !opts[:render][:optimized_layout_method_created] instance.send(:retrieve_template, :template=>layout_template, :cache_key=>nil, :template_method_cache_key => :_roda_layout) layout_method = opts[:render][:template_method_cache][:_roda_layout] define_method(:_layout_method){layout_method} private :_layout_method @@ -608,11 +600,10 @@ elsif template.is_a?(Hash) && template.length == 1 template[:content] end end else - # :nocov: def _cached_template_method(_) nil end def _cached_template_method_key(_) @@ -628,10 +619,9 @@ end def _optimized_view_content(template) nil end - # :nocov: end # Convert template options to single hash when rendering templates using render. def render_template_opts(template, opts)