Skip to content

Commit 884e811

Browse files
authored
feat: switch to rinja (#92)
rinja is a more modern, featureful and maintained fork of askama. It will provide us with a nicer templating system that will most likely get much more attention in the future given it's what is used on docs.rs currently.
1 parent 72bbd4d commit 884e811

File tree

10 files changed

+67
-68
lines changed

10 files changed

+67
-68
lines changed

Cargo.lock

Lines changed: 51 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ pedantic = "warn"
2323

2424
[workspace.dependencies]
2525
anyhow = "1.0.95"
26-
askama = "0.12.1"
27-
askama_derive = "0.12.5"
28-
askama_parser = "0.2.1"
2926
async-stream = "0.3"
3027
async-trait = "0.1"
3128
axum = { version = "0.7", default-features = false }
@@ -52,6 +49,7 @@ hmac = "0.13.0-pre.4"
5249
http = "1.1"
5350
http-body = "1"
5451
http-body-util = "0.1"
52+
humansize = "2.1.3"
5553
indexmap = "2"
5654
mime_guess = { version = "2", default-features = false }
5755
mockall = "0.13"
@@ -61,6 +59,7 @@ prettyplease = "0.2"
6159
proc-macro-crate = "3"
6260
proc-macro2 = { version = "1", default-features = false }
6361
quote = { version = "1", default-features = false }
62+
rinja = "0.3.5"
6463
rustversion = "1"
6564
sea-query = { version = "0.32.0-rc.2", default-features = false }
6665
sea-query-binder = { version = "0.7.0-rc.2", default-features = false }

examples/sessions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ description = "Sessions - Flareon example."
66
edition = "2021"
77

88
[dependencies]
9-
askama = "0.12.1"
109
flareon = { path = "../../flareon" }
10+
rinja = "0.3.5"

examples/sessions/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use askama::Template;
21
use flareon::forms::Form;
32
use flareon::middleware::SessionMiddleware;
43
use flareon::request::{Request, RequestExt};
54
use flareon::response::{Response, ResponseExt};
65
use flareon::router::{Route, Router};
76
use flareon::{reverse, Body, FlareonApp, FlareonProject, StatusCode};
7+
use rinja::Template;
88

99
#[derive(Debug, Template)]
1010
#[template(path = "index.html")]

examples/todo-list/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ description = "TODO List - Flareon example."
66
edition = "2021"
77

88
[dependencies]
9-
askama = "0.12.1"
109
flareon = { path = "../../flareon" }
10+
rinja = "0.3.5"

examples/todo-list/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod migrations;
22

3-
use askama::Template;
43
use flareon::config::{DatabaseConfig, ProjectConfig};
54
use flareon::db::migrations::DynMigration;
65
use flareon::db::{model, query, Model};
@@ -9,6 +8,7 @@ use flareon::request::{Request, RequestExt};
98
use flareon::response::{Response, ResponseExt};
109
use flareon::router::{Route, Router};
1110
use flareon::{reverse, Body, FlareonApp, FlareonProject, StatusCode};
11+
use rinja::Template;
1212

1313
#[derive(Debug, Clone)]
1414
#[model]

flareon/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ description = "Modern web framework focused on speed and ease of use."
99
workspace = true
1010

1111
[dependencies]
12-
askama.workspace = true
13-
askama_derive.workspace = true
14-
askama_parser.workspace = true
1512
async-trait.workspace = true
1613
axum = { workspace = true, features = ["http1", "tokio"] }
1714
backtrace.workspace = true
@@ -28,10 +25,12 @@ hmac.workspace = true
2825
http-body-util.workspace = true
2926
http-body.workspace = true
3027
http.workspace = true
28+
humansize.workspace = true
3129
indexmap.workspace = true
3230
mime_guess.workspace = true
3331
password-auth = { workspace = true, features = ["std", "argon2"] }
3432
pin-project-lite.workspace = true
33+
rinja.workspace = true
3534
sea-query = { workspace = true }
3635
sea-query-binder = { workspace = true, features = ["with-chrono", "runtime-tokio"] }
3736
serde = { workspace = true, features = ["derive"] }
@@ -59,10 +58,9 @@ rustdoc-args = ["--cfg", "docsrs"]
5958

6059
[package.metadata.cargo-machete]
6160
ignored = [
62-
# askama doesn't seem to be working with minimal versions of its dependencies at the moment,
61+
# rinja doesn't seem to be working with minimal versions of its dependencies at the moment,
6362
# so we're manually setting the required versions in the main crate.
64-
"askama_derive",
65-
"askama_parser",
63+
"humansize",
6664
# time requires version 0.3.35 to work with the latest versions of Rust, but we don't use it directly
6765
"time",
6866
]

flareon/src/admin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
use std::marker::PhantomData;
77

8-
use askama::Template;
98
use async_trait::async_trait;
109
use bytes::Bytes;
1110
use derive_more::Debug;
11+
use rinja::Template;
1212

1313
use crate::auth::AuthRequestExt;
1414
use crate::forms::fields::Password;

flareon/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ macro_rules! impl_error_from_repr {
6060
};
6161
}
6262

63-
impl From<Error> for askama::Error {
63+
impl From<Error> for rinja::Error {
6464
fn from(value: Error) -> Self {
65-
askama::Error::Custom(Box::new(value))
65+
rinja::Error::Custom(Box::new(value))
6666
}
6767
}
6868

69-
impl_error_from_repr!(askama::Error);
69+
impl_error_from_repr!(rinja::Error);
7070
impl_error_from_repr!(crate::router::path::ReverseError);
7171
#[cfg(feature = "db")]
7272
impl_error_from_repr!(crate::db::DatabaseError);
@@ -105,7 +105,7 @@ pub(crate) enum ErrorRepr {
105105
ReverseError(#[from] crate::router::path::ReverseError),
106106
/// An error occurred while trying to render a template.
107107
#[error("Failed to render template: {0}")]
108-
TemplateRender(#[from] askama::Error),
108+
TemplateRender(#[from] rinja::Error),
109109
/// An error occurred while communicating with the database.
110110
#[error("Database error: {0}")]
111111
#[cfg(feature = "db")]

flareon/src/error_page.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::any::Any;
22
use std::panic::PanicHookInfo;
33
use std::sync::Arc;
44

5-
use askama::Template;
5+
use rinja::Template;
66
use tracing::error;
77

88
use crate::error::backtrace::{Backtrace, __flareon_create_backtrace};

0 commit comments

Comments
 (0)