Use Ructe (#327)

All the template are now compiled at compile-time with the `ructe` crate.

I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error).

The diff is quite huge, but there is normally no changes in functionality.

Fixes #161 and unblocks #110 and #273
This commit is contained in:
Baptiste Gelez
2018-12-06 18:54:16 +01:00
committed by GitHub
parent 5f059c3e98
commit 70af57c6e1
121 changed files with 3132 additions and 3260 deletions
-5
View File
@@ -1,5 +0,0 @@
{% extends "errors/base" %}
{% block error %}
<h1>{{ "You are not authorized." | _ }}</h1>
{% endblock error %}
-6
View File
@@ -1,6 +0,0 @@
{% extends "errors/base" %}
{% block error %}
<h1>{{ "We couldn't find this page." | _ }}</h1>
<h2>{{ "The link that led you here may be broken." | _ }}</h2>
{% endblock error %}
-6
View File
@@ -1,6 +0,0 @@
{% extends "errors/base" %}
{% block error %}
<h1>{{ "Something broke on our side." | _ }}</h1>
<p>{{ "Sorry about that. If you think this is a bug, please report it." | _ }}</p>
{% endblock error %}
-15
View File
@@ -1,15 +0,0 @@
{% extends "base" %}
{% block title %}
{{ error_message }}
{% endblock title %}
{% block content %}
<main class="error">
{% block error %}
{% endblock error %}
<p>
{{ error_message }}
</p>
</main>
{% endblock content %}
+9
View File
@@ -0,0 +1,9 @@
@use templates::base as base_template;
@use template_utils::*;
@(ctx: BaseContext, error_message: &str, error: Content)
@:base_template(ctx, error_message, {}, {}, {
@:error()
<p>@error_message</p>
})
-6
View File
@@ -1,6 +0,0 @@
{% extends "errors/base" %}
{% block error %}
<h1>{{ "Invalid CSRF token." | _ }}</h1>
<p>{{ "Something is wrong with your CSRF token. Make sure cookies are enabled in you browser, and try reloading this page. If you continue to see this error message, please report it." | _ }}</p>
{% endblock error %}
+12
View File
@@ -0,0 +1,12 @@
@use templates::errors::base;
@use template_utils::*;
@(ctx: BaseContext)
@:base(ctx, "", {
<h1>@i18n!(ctx.1, "Invalid CSRF token.")</h1>
<p>@i18n!(ctx.1, r#"Something is wrong with your CSRF token.
Make sure cookies are enabled in you browser, and try reloading this page.
If you continue to see this error message, please report it."#)
</p>
})
+8
View File
@@ -0,0 +1,8 @@
@use templates::errors::base;
@use template_utils::*;
@(ctx: BaseContext, error_message: &str)
@:base(ctx, error_message, {
<h1>@i18n!(ctx.1, "You are not authorized.")</h1>
})
+10
View File
@@ -0,0 +1,10 @@
@use templates::errors::base;
@use template_utils::*;
@(ctx: BaseContext)
@:base(ctx, "Page not found", {
<h1>@i18n!(ctx.1, "We couldn't find this page.")</h1>
<p>@i18n!(ctx.1, "The link that led you here may be broken.")</p>
})
+9
View File
@@ -0,0 +1,9 @@
@use templates::errors::base;
@use template_utils::*;
@(ctx: BaseContext)
@:base(ctx, "Internal server error", {
<h1>@i18n!(ctx.1, "Something broke on our side.")</h1>
<p>@i18n!(ctx.1, "Sorry about that. If you think this is a bug, please report it.")</p>
})