Skip to content

Commit 8ef19e5

Browse files
GuillaumeGomezsyphar
authored andcommitted
Update askama version to 0.14.0
1 parent f759505 commit 8ef19e5

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ tempfile = "3.1.0"
9090
fn-error-context = "0.2.0"
9191

9292
# Templating
93-
askama = "0.13.1"
93+
askama = "0.14.0"
9494
walkdir = "2"
9595

9696
# Date and Time utilities

src/web/highlight.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn with_lang(lang: Option<&str>, code: &str, default: Option<&str>) -> Strin
8282
} else {
8383
log::error!("failed while highlighting code: {err:?}");
8484
}
85-
crate::web::page::templates::filters::escape_html(code)
85+
crate::web::page::templates::filters::escape_html(code, &())
8686
.map(|s| s.to_string())
8787
.unwrap_or_default()
8888
}

src/web/page/templates.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ impl TemplateData {
8888
}
8989

9090
pub mod filters {
91+
use askama::Values;
9192
use askama::filters::Safe;
9293
use chrono::{DateTime, Utc};
9394
use std::borrow::Cow;
9495

9596
// Copied from `tera`.
96-
pub fn escape_html(input: &str) -> askama::Result<Cow<'_, str>> {
97+
pub fn escape_html<'a>(input: &'a str, _: &dyn Values) -> askama::Result<Cow<'a, str>> {
9798
if !input.chars().any(|c| "&<>\"'/".contains(c)) {
9899
return Ok(Cow::Borrowed(input));
99100
}
@@ -115,7 +116,7 @@ pub mod filters {
115116
}
116117

117118
// Copied from `tera`.
118-
pub fn escape_xml(input: &str) -> askama::Result<Cow<'_, str>> {
119+
pub fn escape_xml<'a>(input: &'a str, _: &dyn Values) -> askama::Result<Cow<'a, str>> {
119120
if !input.chars().any(|c| "&<>\"'".contains(c)) {
120121
return Ok(Cow::Borrowed(input));
121122
}
@@ -135,11 +136,11 @@ pub mod filters {
135136

136137
/// Prettily format a timestamp
137138
// TODO: This can be replaced by chrono
138-
pub fn timeformat(value: &DateTime<Utc>) -> askama::Result<String> {
139+
pub fn timeformat(value: &DateTime<Utc>, _: &dyn Values) -> askama::Result<String> {
139140
Ok(crate::web::duration_to_str(*value))
140141
}
141142

142-
pub fn format_secs(mut value: f32) -> askama::Result<String> {
143+
pub fn format_secs(mut value: f32, _: &dyn Values) -> askama::Result<String> {
143144
const TIMES: &[&str] = &["seconds", "minutes", "hours"];
144145

145146
let mut chosen_time = &TIMES[0];
@@ -166,6 +167,7 @@ pub mod filters {
166167
#[allow(clippy::unnecessary_wraps)]
167168
pub fn dedent<T: std::fmt::Display, I: Into<Option<i32>>>(
168169
value: T,
170+
_: &dyn Values,
169171
levels: I,
170172
) -> askama::Result<String> {
171173
let string = value.to_string();
@@ -200,7 +202,11 @@ pub mod filters {
200202
Ok(unindented)
201203
}
202204

203-
pub fn highlight(code: impl std::fmt::Display, lang: &str) -> askama::Result<Safe<String>> {
205+
pub fn highlight(
206+
code: impl std::fmt::Display,
207+
_: &dyn Values,
208+
lang: &str,
209+
) -> askama::Result<Safe<String>> {
204210
let highlighted_code =
205211
crate::web::highlight::with_lang(Some(lang), &code.to_string(), None);
206212
Ok(Safe(format!(
@@ -209,7 +215,7 @@ pub mod filters {
209215
)))
210216
}
211217

212-
pub fn round(value: &f32, precision: u32) -> askama::Result<String> {
218+
pub fn round(value: &f32, _: &dyn Values, precision: u32) -> askama::Result<String> {
213219
let multiplier = if precision == 0 {
214220
1.0
215221
} else {
@@ -218,11 +224,18 @@ pub mod filters {
218224
Ok(((multiplier * *value).round() / multiplier).to_string())
219225
}
220226

221-
pub fn split_first<'a>(value: &'a str, pat: &str) -> askama::Result<Option<&'a str>> {
227+
pub fn split_first<'a>(
228+
value: &'a str,
229+
_: &dyn Values,
230+
pat: &str,
231+
) -> askama::Result<Option<&'a str>> {
222232
Ok(value.split(pat).next())
223233
}
224234

225-
pub fn json_encode<T: ?Sized + serde::Serialize>(value: &T) -> askama::Result<Safe<String>> {
235+
pub fn json_encode<T: ?Sized + serde::Serialize>(
236+
value: &T,
237+
_: &dyn Values,
238+
) -> askama::Result<Safe<String>> {
226239
Ok(Safe(
227240
serde_json::to_string(value).expect("`encode_json` failed"),
228241
))

templates/releases/search_results.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{%- endblock header -%}
77

88
{%- block topbar -%}
9-
{% let search_query = search_query %}
9+
{% let search_query = &search_query %}
1010
{%- include "header/topbar.html" -%}
1111
{%- endblock topbar -%}
1212

0 commit comments

Comments
 (0)