Base: Use % for keys in templates

The previous character used, @, conflicted with CSS. % is used by other
templating engines, and doesn't conflict with language features (e.g.
media queries).
This commit is contained in:
Jamie Mansfield 2024-07-07 20:08:09 +01:00 committed by Andreas Kling
parent 634f2f655b
commit 27f3305b87
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00
4 changed files with 17 additions and 17 deletions

View file

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8">
<title>Index of @path@</title>
<title>Index of %path%</title>
<style>
header {
margin-bottom: 10px;
@ -51,11 +51,11 @@
<body>
<header>
<span class="folder" style="width: 24px; height: 24px;"></span>
<h1>Index of @path@</h1>
<h1>Index of %path%</h1>
</header>
<p><a href="@parent_url@"><span class="open-parent"></span>Open Parent Directory</a></p>
<p><a href="%parent_url%"><span class="open-parent"></span>Open Parent Directory</a></p>
<hr>
@contents@
%contents%
<hr>
</body>
</html>

View file

@ -20,8 +20,8 @@
<body>
<header>
<img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
<h1>Failed to load @failed_url@</h1>
<h1>Failed to load %failed_url%</h1>
</header>
<p>@error_message@</p>
<p>%error_message%</p>
</body>
</html>

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About @browser_name@</title>
<title>About %browser_name%</title>
<style>
img {
float: left;
@ -20,32 +20,32 @@
<body>
<header>
<img src="resource://icons/128x128/app-browser.png">
<h1>About @browser_name@</h1>
<h1>About %browser_name%</h1>
</header>
<table>
<tr>
<th>Version:</th>
<td>@browser_version@</td>
<td>%browser_version%</td>
</tr>
<tr>
<th>Arch:</th>
<td>@arch_name@</td>
<td>%arch_name%</td>
</tr>
<tr>
<th>Operating System:</th>
<td>@os_name@</td>
<td>%os_name%</td>
</tr>
<tr>
<th>User Agent:</th>
<td>@user_agent@</td>
<td>%user_agent%</td>
</tr>
<tr>
<th>Command Line:</th>
<td>@command_line@</td>
<td>%command_line%</td>
</tr>
<tr>
<th>Executable Path:</th>
<td>@executable_path@</td>
<td>%executable_path%</td>
</tr>
</table>
</body>

View file

@ -32,7 +32,7 @@ ErrorOr<String> load_error_page(URL::URL const& url, StringView error_message)
// 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/error.html"sv));
StringBuilder builder;
SourceGenerator generator { builder };
SourceGenerator generator { builder, '%', '%' };
generator.set("failed_url", url.to_byte_string());
generator.set("error_message", escape_html_entities(error_message));
generator.append(template_file->data());
@ -72,7 +72,7 @@ ErrorOr<String> load_file_directory_page(URL::URL const& url)
// 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/directory.html"sv));
StringBuilder builder;
SourceGenerator generator { 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());
@ -86,7 +86,7 @@ ErrorOr<String> load_about_version_page()
// 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_file = TRY(Core::Resource::load_from_uri("resource://ladybird/templates/version.html"sv));
StringBuilder builder;
SourceGenerator generator { builder };
SourceGenerator generator { builder, '%', '%' };
generator.set("browser_name", BROWSER_NAME);
generator.set("browser_version", BROWSER_VERSION);
generator.set("arch_name", CPU_STRING);