def render(
      string_or_file,
      dir: render_defaults[:dir],
      layout: @_no_default_layout ? nil : render_defaults[:layout],
      engine: render_defaults[:engine],
      locals: render_defaults[:locals],
      tilt: render_defaults[:tilt],
      **options,
      &block
    )
      template_cache = config[:cache_templates] ? TemplateCache : Tilt::Cache.new
      tilt_options = options.merge(tilt || {})
      tilt_engine = (derived_engine = Tilt[string_or_file.to_s]) || Tilt[engine]
      raise Error, "Invalid or undefined template engine: #{engine.inspect}" unless tilt_engine

      template = if Symbol === string_or_file
        file = string_or_file.to_s
        file = file << ".#{engine}" unless derived_engine
        file = File.expand_path(file, dir) if dir

        template_cache.fetch(:file, tilt_engine, file, tilt_options) do
          tilt_engine.new(file, nil, tilt_options)
        end
      else
        template_cache.fetch(:string, tilt_engine, string_or_file, tilt_options) do
          tilt_engine.new(nil, nil, tilt_options) { string_or_file }
        end
      end

      # The following is responsible for preventing the rendering of layouts within views.
      begin
        original_no_default_layout = @_no_default_layout
        @_no_default_layout = true
        output = template.render(self, locals, &block)
      ensure
        @_no_default_layout = original_no_default_layout
      end

      if layout
        render(layout, dir: dir, layout: false, engine: engine, locals: locals, tilt: tilt, **options) { output }
      else
        output
      end
    end
def render(
      string_or_file,
      dir: render_defaults[:dir],
      layout: @_no_default_layout ? nil : render_defaults[:layout],
      engine: render_defaults[:engine],
      locals: render_defaults[:locals],
      tilt: render_defaults[:tilt],
      **options,
      &block
    )
      template_cache = config[:cache_templates] ? TemplateCache : Tilt::Cache.new
      tilt_options = options.merge(tilt || {})
      tilt_engine = (derived_engine = Tilt[string_or_file.to_s]) || Tilt[engine]
      raise Error, "Invalid or undefined template engine: #{engine.inspect}" unless tilt_engine

      template = if Symbol === string_or_file
        file = string_or_file.to_s
        file = file << ".#{engine}" unless derived_engine
        file = File.expand_path(file, dir) if dir

        template_cache.fetch(:file, tilt_engine, file, tilt_options) do
          tilt_engine.new(file, nil, tilt_options)
        end
      else
        template_cache.fetch(:string, tilt_engine, string_or_file, tilt_options) do
          tilt_engine.new(nil, nil, tilt_options) { string_or_file }
        end
      end

      # The following is responsible for preventing the rendering of layouts within views.
      begin
        original_no_default_layout = @_no_default_layout
        @_no_default_layout = true
        output = template.render(self, locals, &block)
      ensure
        @_no_default_layout = original_no_default_layout
      end

      if layout
        render(layout, dir: dir, layout: false, engine: engine, locals: locals, tilt: tilt, **options) { output }
      else
        output
      end
    end
Renders the given string or file path using the Tilt templating library.
 Each option defaults to the corresponding value defined in _render_defaults_ attribute. Unrecognised options are
 passed through to Tilt, but a `:tilt` option is also provided for passing options directly to Tilt.
 The template engine is derived from the file name, or otherwise as specified by the _:engine_ option. If a string
 is given, the _:engine_ option must be set.

 Refer to Tilt documentation for a list of valid template engines and Tilt options.