module Roda::RodaPlugins::Render::InstanceMethods

def cached_template(opts, &block)

to get the template.
If caching templates, attempt to retrieve the template from the cache. Otherwise, just yield
def cached_template(opts, &block)
  if cache = render_opts[:cache]
    key = opts[:key]
    unless template = cache[key]
      template = cache[key] = yield
    end
    template
  else
    yield
  end
end

def find_template(opts)

and template block to use for the render.
Given the template name and options, return the template class, template path/content,
def find_template(opts)
  if content = opts[:inline]
    path = opts[:path] = content
    template_class = opts[:template_class] ||= ::Tilt[opts[:engine] || render_opts[:engine]]
    opts[:template_block] = Proc.new{content}
  else
    path = opts[:path] ||= template_path(opts)
    template_class = opts[:template_class]
    opts[:template_class] ||= ::Tilt
  end
  if render_opts[:cache]
    template_opts = opts[:template_opts]
    if opts[:opts] && !template_opts
      RodaPlugins.deprecate("The render method :opts option is deprecated and will be removed in Roda 2.  Switch to using the :template_opts option")
      template_opts = opts[:opts]
    end
    template_block = opts[:template_block] if !content
    key = if template_class || template_opts || template_block
      [path, template_class, template_opts, template_block]
    else
      path
    end
    opts[:key] = key
  end
  opts
end

def parse_template_opts(template, opts)

Return a single hash combining the template and opts arguments.
def parse_template_opts(template, opts)
  template = {:template=>template} unless template.is_a?(Hash)
  opts.merge(template)
end

def render(template, opts = OPTS, &block)

Render the given template. See Render for details.
def render(template, opts = OPTS, &block)
  opts = find_template(parse_template_opts(template, opts))
  cached_template(opts) do
    template_opts = render_opts[:template_opts]
    current_template_opts = opts[:template_opts]
    if opts[:opts] && !current_template_opts
      RodaPlugins.deprecate("The render method :opts option is deprecated and will be removed in Roda 2.  Switch to using the :template_opts option")
      current_template_opts = opts[:opts]
    end
    template_opts = template_opts.merge(current_template_opts) if current_template_opts
    opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block])
  end.render(self, (opts[:locals]||OPTS), &block)
end

def render_opts

so you should not attempt to modify it.
is not currently frozen, it may be frozen in a future version,
Return the render options for the instance's class. While this
def render_opts
  self.class.render_opts
end

def template_name(opts)

The name to use for the template. By default, just converts the :template option to a string.
def template_name(opts)
  opts[:template].to_s
end

def template_path(opts)

The path for the given template.
def template_path(opts)
  render_opts = render_opts()
  "#{opts[:views] || render_opts[:views]}/#{template_name(opts)}.#{opts[:ext] || render_opts[:ext] || render_opts[:engine]}"
end

def view(template, opts=OPTS)

and render it inside the layout. See Render for details.
for the class, take the result of the template rendering
Render the given template. If there is a default layout
def view(template, opts=OPTS)
  opts = parse_template_opts(template, opts)
  content = opts[:content] || render(opts)
  if layout = opts.fetch(:layout, (OPTS if render_opts[:layout]))
    layout_opts = render_opts[:layout_opts] 
    if opts[:layout_opts]
      layout_opts = opts[:layout_opts].merge(layout_opts)
    end
    content = render(layout, layout_opts){content}
  end
  content
end