diff --git a/Base/res/ladybird/directory.html b/Base/res/ladybird/directory.html
deleted file mode 100644
index aeb9ef8b73..0000000000
--- a/Base/res/ladybird/directory.html
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- Index of @path@
-
-
-
-
- Open Parent Directory
-
- @contents@
-
-
-
diff --git a/Base/res/ladybird/error.html b/Base/res/ladybird/error.html
deleted file mode 100644
index 81a2c5831a..0000000000
--- a/Base/res/ladybird/error.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- Error!
-
-
-
-
-
- Failed to load @failed_url@
-
-
-
diff --git a/Base/res/ladybird/templates/directory.html b/Base/res/ladybird/templates/directory.html
new file mode 100644
index 0000000000..ef96bc2f7d
--- /dev/null
+++ b/Base/res/ladybird/templates/directory.html
@@ -0,0 +1,61 @@
+
+
+
+
+ Index of @path@
+
+
+
+
+ Open Parent Directory
+
+ @contents@
+
+
+
diff --git a/Base/res/ladybird/templates/error.html b/Base/res/ladybird/templates/error.html
new file mode 100644
index 0000000000..371d7613c5
--- /dev/null
+++ b/Base/res/ladybird/templates/error.html
@@ -0,0 +1,26 @@
+
+
+
+
+ Error!
+
+
+
+
+
+ Failed to load @failed_url@
+
+
+
diff --git a/Meta/gn/secondary/Ladybird/BUILD.gn b/Meta/gn/secondary/Ladybird/BUILD.gn
index 33aef0e58f..6b394757f0 100644
--- a/Meta/gn/secondary/Ladybird/BUILD.gn
+++ b/Meta/gn/secondary/Ladybird/BUILD.gn
@@ -294,11 +294,11 @@ if (current_os == "mac") {
bundle_data("ladybird_web_resources") {
sources = [
- "//Base/res/ladybird/directory.html",
- "//Base/res/ladybird/error.html",
"//Base/res/ladybird/inspector.css",
"//Base/res/ladybird/inspector.js",
"//Base/res/ladybird/new-tab.html",
+ "//Base/res/ladybird/templates/directory.html",
+ "//Base/res/ladybird/templates/error.html",
]
outputs = [ "{{bundle_resources_dir}}/res/ladybird/{{source_file_part}}" ]
}
diff --git a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp
index e6f8706fdd..5eb4f8735c 100644
--- a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp
@@ -19,13 +19,11 @@ ErrorOr load_error_page(AK::URL const& url)
{
// Generate HTML error page from error template file
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time)
- auto template_path = TRY(Core::Resource::load_from_uri("resource://ladybird/error.html"sv))->filesystem_path();
- auto template_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
- auto template_contents = TRY(template_file->read_until_eof());
+ auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/error.html"sv));
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("failed_url", url.to_byte_string());
- generator.append(template_contents);
+ generator.append(template_file->data());
return TRY(String::from_utf8(generator.as_string_view()));
}
@@ -60,15 +58,13 @@ ErrorOr load_file_directory_page(AK::URL const& url)
// Generate HTML directory page from directory template file
// FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time)
- auto template_path = TRY(Core::Resource::load_from_uri("resource://ladybird/directory.html"sv))->filesystem_path();
- auto template_file = TRY(Core::File::open(template_path, Core::File::OpenMode::Read));
- auto template_contents = TRY(template_file->read_until_eof());
+ auto template_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/directory.html"sv));
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("path", escape_html_entities(lexical_path.string()));
generator.set("parent_url", TRY(String::formatted("file://{}", escape_html_entities(lexical_path.parent().string()))));
generator.set("contents", contents.to_byte_string());
- generator.append(template_contents);
+ generator.append(template_file->data());
return TRY(String::from_utf8(generator.as_string_view()));
}