class Tilt::Template

def bind_compiled_method(method_source, offset, scope_class)

def bind_compiled_method(method_source, offset, scope_class)
  path = compiled_path
  if path && scope_class.name
    path = path.dup
    if defined?(@compiled_path_counter)
      path << '-' << @compiled_path_counter.succ!
    else
      @compiled_path_counter = "0".dup
    end
    path << ".rb"
    # Wrap method source in a class block for the scope, so constant lookup works
    if freeze_string_literals?
      method_source_prefix = "# frozen-string-literal: true\n"
      method_source = method_source.sub(/\A# frozen-string-literal: true\n/, '')
    end
    method_source = "#{method_source_prefix}class #{scope_class.name}\n#{method_source}\nend"
    load_compiled_method(path, method_source)
  else
    if path
      warn "compiled_path (#{compiled_path.inspect}) ignored on template with anonymous scope_class (#{scope_class.inspect})"
    end
    eval_compiled_method(method_source, offset, scope_class)
  end
end