def filter_files(files, path, path_without_extension, template_extensions)
      results = []

      files.each do |file|
        match = if file.start_with?(path)
                  path
                else
                  path_without_extension
                end

        processable_extensions = file[(match.length + 1)..-1].split(".")

        # All processable_extensions must be processable
        # by a template_extension
        next unless (processable_extensions - template_extensions).empty?

        if file.start_with?(path)
          # The whole path is found in the filename, not just
          # the path without the extension.
          # it must have priority over all else
          results.unshift(file)
        else
          results.push(file)
        end
      end
      results
    end
def filter_files(files, path, path_without_extension, template_extensions)
      results = []

      files.each do |file|
        match = if file.start_with?(path)
                  path
                else
                  path_without_extension
                end

        processable_extensions = file[(match.length + 1)..-1].split(".")

        # All processable_extensions must be processable
        # by a template_extension
        next unless (processable_extensions - template_extensions).empty?

        if file.start_with?(path)
          # The whole path is found in the filename, not just
          # the path without the extension.
          # it must have priority over all else
          results.unshift(file)
        else
          results.push(file)
        end
      end
      results
    end
Filter a list of files to see wether or not we can process them.
 Will take into account that the longest match with path will
 be the first result.