module Roda::RodaPlugins::Render::ClassMethods

def _freeze_layout_method

Precompile the layout method, to reduce method calls to look it up at runtime.
def _freeze_layout_method
  if render_opts[:layout]
    instance = allocate
    instance.send(:retrieve_template, instance.send(:view_layout_opts, OPTS))
    if COMPILED_METHOD_SUPPORT
      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
        alias_method(:_layout_method, :_layout_method)
        opts[:render] = opts[:render].merge(:optimized_layout_method_created=>true)
      end
    end
  end
end

def create_template(opts, template_opts)

Return an Tilt::Template object based on the given opts and template_opts.
def create_template(opts, template_opts)
  opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block])
end

def freeze

access to the layout method to improve the performance of view.
If using compiled methods and there is an optimized layout, speed up
def freeze
  begin
    _freeze_layout_method
  rescue
    # This is only for optimization, if any errors occur, they can be ignored.
    # One possibility for error is the app doesn't use a layout, but doesn't
    # specifically set the :layout=>false plugin option.
    nil
  end
  super
end

def inherited(subclass)

affecting the parent class.
them as necessary to prevent changes in the subclass
Copy the rendering options into the subclass, duping
def inherited(subclass)
  super
  opts = subclass.opts[:render] = subclass.opts[:render].dup
  if COMPILED_METHOD_SUPPORT
    opts[:template_method_cache] = (opts[:cache_class] || RodaCache).new
  end
  opts[:cache] = opts[:cache].dup
  opts.freeze
end

def inline_template_block(content)

doesn't hold a reference to the instance of the class
A proc that returns content, used for inline templates, so that the template
def inline_template_block(content)
  Proc.new{content}
end

def render_opts

Return the render options for this class.
def render_opts
  opts[:render]
end