     end
   end
 
-  @spec compile_include(Serum.File.t()) :: Result.t({binary(), Template.t()})
-  defp compile_include(file) do
+  @spec compile_internal(Serum.File.t(), Template.template_type()) ::
+          Result.t({binary(), Template.t()})
+  defp compile_internal(file, type) do
     path = file.src
     name = Path.basename(path, ".html.eex")
 
-    case compile(file.in_data, :include) do
-      {:ok, ast} -> {:ok, {name, Template.new(ast, :include, path)}}
+    case compile(file.in_data, type) do
+      {:ok, ast} -> {:ok, {name, Template.new(ast, type, path)}}
       {:ct_error, msg, line} -> {:error, {msg, path, line}}
     end
   end

  def load_includes(files) do
    result =
      files
      |> Task.async_stream(&compile_include/1)
      |> Enum.map(&elem(&1, 1))
      |> Result.aggregate_values(:template_loader)


  def load_templates(files) do
    result =
      files
      |> Task.async_stream(&compile_internal(&1, :template))
      |> Enum.map(&elem(&1, 1))
      |> Result.aggregate_values(:template_loader)

    case result do
      {:ok, list} -> list |> Map.new() |> Template.load(:template)
      {:error, _} = error -> error
    end
  end

