module Middleman::CoreExtensions::Rendering::InstanceMethods

def render_individual_file(path, locs = {}, opts = {}, context = self, &block)

Returns:
  • (String) -

Parameters:
  • context (Class) --
  • opts (Hash) --
  • locs (Hash) --
  • path (String, Symbol) --
def render_individual_file(path, locs = {}, opts = {}, context = self, &block)
  path = path.to_s
  # Save current buffer for later
  @_out_buf, _buf_was = "", @_out_buf
  # Read from disk or cache the contents of the file
  body = if opts[:template_body]
    opts.delete(:template_body)
  else
    template_data_for_file(path)
  end
  # Merge per-extension options from config
  extension = File.extname(path)
  options = opts.merge(options_for_ext(extension))
  options[:outvar] ||= '@_out_buf'
  # Read compiled template from disk or cache
  template = cache.fetch(:compiled_template, options, body) do
    ::Tilt.new(path, 1, options) { body }
  end
  # Render using Tilt
  template.render(context, locs, &block)
ensure
  # Reset stored buffer
  @_out_buf = _buf_was
end