def extract_handler_and_format_and_variant(path)
        pieces = File.basename(path).split(".")
        pieces.shift

        extension = pieces.pop

        handler = Template.handler_for_extension(extension)
        format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
        format = if format
          Template::Types[format]&.ref
        else
          if handler.respond_to?(:default_format) # default_format can return nil
            handler.default_format
          else
            nil
          end
        end

        # Template::Types[format] and handler.default_format can return nil
        [handler, format, variant]
      end
def extract_handler_and_format_and_variant(path)
        pieces = File.basename(path).split(".")
        pieces.shift

        extension = pieces.pop

        handler = Template.handler_for_extension(extension)
        format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
        format = if format
          Template::Types[format]&.ref
        else
          if handler.respond_to?(:default_format) # default_format can return nil
            handler.default_format
          else
            nil
          end
        end

        # Template::Types[format] and handler.default_format can return nil
        [handler, format, variant]
      end
Extract handler, formats and variant from path. If a format cannot be found neither
 from the path, or the handler, we should return the array of formats given
 to the resolver.