mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-27 13:00:57 +00:00
Apply clippy suggestions for 1.67 (#769)
This commit is contained in:
parent
23326b4765
commit
3003d86264
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "../README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
@ -56,10 +56,10 @@ impl std::error::Error for Error {
|
||||
impl Display for Error {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Fmt(err) => write!(formatter, "formatting error: {}", err),
|
||||
Error::Custom(err) => write!(formatter, "{}", err),
|
||||
Error::Fmt(err) => write!(formatter, "formatting error: {err}"),
|
||||
Error::Custom(err) => write!(formatter, "{err}"),
|
||||
#[cfg(feature = "serde_json")]
|
||||
Error::Json(err) => write!(formatter, "json conversion error: {}", err),
|
||||
Error::Json(err) => write!(formatter, "json conversion error: {err}"),
|
||||
#[cfg(feature = "serde_yaml")]
|
||||
Error::Yaml(err) => write!(formatter, "yaml conversion error: {}", err),
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ pub fn linebreaks<T: fmt::Display>(s: T) -> Result<String> {
|
||||
let s = s.to_string();
|
||||
let linebroken = s.replace("\n\n", "</p><p>").replace('\n', "<br/>");
|
||||
|
||||
Ok(format!("<p>{}</p>", linebroken))
|
||||
Ok(format!("<p>{linebroken}</p>"))
|
||||
}
|
||||
|
||||
/// Converts all newlines in a piece of plain text to HTML line breaks
|
||||
@ -181,7 +181,7 @@ pub fn paragraphbreaks<T: fmt::Display>(s: T) -> Result<String> {
|
||||
let s = s.to_string();
|
||||
let linebroken = s.replace("\n\n", "</p><p>").replace("<p></p>", "");
|
||||
|
||||
Ok(format!("<p>{}</p>", linebroken))
|
||||
Ok(format!("<p>{linebroken}</p>"))
|
||||
}
|
||||
|
||||
/// Converts to lowercase
|
||||
@ -279,7 +279,7 @@ where
|
||||
rv.push_str(separator);
|
||||
}
|
||||
|
||||
write!(rv, "{}", item)?;
|
||||
write!(rv, "{item}")?;
|
||||
}
|
||||
|
||||
Ok(rv)
|
||||
|
@ -93,7 +93,7 @@ pub trait Template: fmt::Display {
|
||||
/// Renders the template to the given `writer` io buffer
|
||||
#[inline]
|
||||
fn write_into(&self, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
|
||||
writer.write_fmt(format_args!("{}", self))
|
||||
writer.write_fmt(format_args!("{self}"))
|
||||
}
|
||||
|
||||
/// The template's extension, if provided
|
||||
@ -140,7 +140,7 @@ impl<T: Template> DynTemplate for T {
|
||||
|
||||
#[inline]
|
||||
fn dyn_write_into(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()> {
|
||||
writer.write_fmt(format_args!("{}", self))
|
||||
writer.write_fmt(format_args!("{self}"))
|
||||
}
|
||||
|
||||
fn extension(&self) -> Option<&'static str> {
|
||||
@ -201,7 +201,7 @@ mod tests {
|
||||
|
||||
assert_eq!(test.to_string(), "test");
|
||||
|
||||
assert_eq!(format!("{}", test), "test");
|
||||
assert_eq!(format!("{test}"), "test");
|
||||
|
||||
let mut vec = Vec::new();
|
||||
test.dyn_write_into(&mut vec).unwrap();
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
actix-web = { version = "4", default-features = false }
|
||||
|
@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "askama_axum"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
description = "Axum integration for Askama templates"
|
||||
keywords = ["markup", "template", "jinja2", "html", "axum"]
|
||||
categories = ["template-engine"]
|
||||
|
@ -7,7 +7,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT/Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::convert::TryFrom;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{env, fs};
|
||||
|
||||
@ -58,13 +57,13 @@ impl Config<'_> {
|
||||
.insert(name.to_string(), Syntax::try_from(raw_s)?)
|
||||
.is_some()
|
||||
{
|
||||
return Err(format!("syntax \"{}\" is already defined", name).into());
|
||||
return Err(format!("syntax \"{name}\" is already defined").into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !syntaxes.contains_key(default_syntax) {
|
||||
return Err(format!("default syntax \"{}\" not found", default_syntax).into());
|
||||
return Err(format!("default syntax \"{default_syntax}\" not found").into());
|
||||
}
|
||||
|
||||
let mut escapers = Vec::new();
|
||||
@ -193,7 +192,7 @@ struct RawConfig<'d> {
|
||||
impl RawConfig<'_> {
|
||||
#[cfg(feature = "config")]
|
||||
fn from_toml_str(s: &str) -> std::result::Result<RawConfig<'_>, CompileError> {
|
||||
toml::from_str(s).map_err(|e| format!("invalid TOML in {}: {}", CONFIG_FILE_NAME, e).into())
|
||||
toml::from_str(s).map_err(|e| format!("invalid TOML in {CONFIG_FILE_NAME}: {e}").into())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "config"))]
|
||||
|
@ -70,7 +70,7 @@ fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileError> {
|
||||
)
|
||||
.build(&contexts[input.path.as_path()])?;
|
||||
if input.print == Print::Code || input.print == Print::All {
|
||||
eprintln!("{}", code);
|
||||
eprintln!("{code}");
|
||||
}
|
||||
Ok(code)
|
||||
}
|
||||
@ -106,7 +106,7 @@ impl TemplateArgs {
|
||||
template_args = Some(nested);
|
||||
}
|
||||
Ok(_) => return Err("'template' attribute must be a list".into()),
|
||||
Err(e) => return Err(format!("unable to parse attribute: {}", e).into()),
|
||||
Err(e) => return Err(format!("unable to parse attribute: {e}").into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ impl TemplateArgs {
|
||||
return Err("config value must be string literal".into());
|
||||
}
|
||||
} else {
|
||||
return Err(format!("unsupported attribute key {:?} found", ident).into());
|
||||
return Err(format!("unsupported attribute key {ident:?} found").into());
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ impl<'a> Generator<'a> {
|
||||
buf.writeln(";")?;
|
||||
|
||||
buf.writeln("const SIZE_HINT: ::std::primitive::usize = ")?;
|
||||
buf.writeln(&format!("{}", size_hint))?;
|
||||
buf.writeln(&format!("{size_hint}"))?;
|
||||
buf.writeln(";")?;
|
||||
|
||||
buf.writeln("const MIME_TYPE: &'static ::std::primitive::str = ")?;
|
||||
@ -478,7 +478,7 @@ impl<'a> Generator<'a> {
|
||||
buf.writeln(
|
||||
format!(
|
||||
"{} {} for {} {} {{",
|
||||
quote!(impl#impl_generics),
|
||||
quote!(impl #impl_generics),
|
||||
"::mendes::application::IntoResponse<A>",
|
||||
self.input.ast.ident,
|
||||
quote!(#orig_ty_generics #where_clause),
|
||||
@ -573,7 +573,7 @@ impl<'a> Generator<'a> {
|
||||
buf.writeln(
|
||||
format!(
|
||||
"{} {} for {}{} {{",
|
||||
quote!(impl#impl_generics),
|
||||
quote!(impl #impl_generics),
|
||||
target,
|
||||
self.input.ast.ident,
|
||||
quote!(#orig_ty_generics #where_clause),
|
||||
@ -755,7 +755,7 @@ impl<'a> Generator<'a> {
|
||||
let mut arm_sizes = Vec::new();
|
||||
|
||||
let expr_code = self.visit_expr_root(expr)?;
|
||||
buf.writeln(&format!("match &{} {{", expr_code))?;
|
||||
buf.writeln(&format!("match &{expr_code} {{"))?;
|
||||
|
||||
let mut arm_size = 0;
|
||||
for (i, arm) in arms.iter().enumerate() {
|
||||
@ -802,24 +802,24 @@ impl<'a> Generator<'a> {
|
||||
buf.writeln("{")?;
|
||||
buf.writeln("let mut _did_loop = false;")?;
|
||||
match loop_block.iter {
|
||||
Expr::Range(_, _, _) => buf.writeln(&format!("let _iter = {};", expr_code)),
|
||||
Expr::Array(..) => buf.writeln(&format!("let _iter = {}.iter();", expr_code)),
|
||||
Expr::Range(_, _, _) => buf.writeln(&format!("let _iter = {expr_code};")),
|
||||
Expr::Array(..) => buf.writeln(&format!("let _iter = {expr_code}.iter();")),
|
||||
// If `iter` is a call then we assume it's something that returns
|
||||
// an iterator. If not then the user can explicitly add the needed
|
||||
// call without issues.
|
||||
Expr::Call(..) | Expr::Index(..) => {
|
||||
buf.writeln(&format!("let _iter = ({}).into_iter();", expr_code))
|
||||
buf.writeln(&format!("let _iter = ({expr_code}).into_iter();"))
|
||||
}
|
||||
// If accessing `self` then it most likely needs to be
|
||||
// borrowed, to prevent an attempt of moving.
|
||||
_ if expr_code.starts_with("self.") => {
|
||||
buf.writeln(&format!("let _iter = (&{}).into_iter();", expr_code))
|
||||
buf.writeln(&format!("let _iter = (&{expr_code}).into_iter();"))
|
||||
}
|
||||
// If accessing a field then it most likely needs to be
|
||||
// borrowed, to prevent an attempt of moving.
|
||||
Expr::Attr(..) => buf.writeln(&format!("let _iter = (&{}).into_iter();", expr_code)),
|
||||
Expr::Attr(..) => buf.writeln(&format!("let _iter = (&{expr_code}).into_iter();")),
|
||||
// Otherwise, we borrow `iter` assuming that it implements `IntoIterator`.
|
||||
_ => buf.writeln(&format!("let _iter = ({}).into_iter();", expr_code)),
|
||||
_ => buf.writeln(&format!("let _iter = ({expr_code}).into_iter();")),
|
||||
}?;
|
||||
if let Some(cond) = &loop_block.cond {
|
||||
self.locals.push();
|
||||
@ -872,13 +872,14 @@ impl<'a> Generator<'a> {
|
||||
let (def, own_ctx) = match scope {
|
||||
Some(s) => {
|
||||
let path = ctx.imports.get(s).ok_or_else(|| {
|
||||
CompileError::from(format!("no import found for scope {:?}", s))
|
||||
})?;
|
||||
let mctx = self.contexts.get(path.as_path()).ok_or_else(|| {
|
||||
CompileError::from(format!("context for {:?} not found", path))
|
||||
CompileError::from(format!("no import found for scope {s:?}"))
|
||||
})?;
|
||||
let mctx = self
|
||||
.contexts
|
||||
.get(path.as_path())
|
||||
.ok_or_else(|| CompileError::from(format!("context for {path:?} not found")))?;
|
||||
let def = mctx.macros.get(name).ok_or_else(|| {
|
||||
CompileError::from(format!("macro {:?} not found in scope {:?}", name, s))
|
||||
CompileError::from(format!("macro {name:?} not found in scope {s:?}"))
|
||||
})?;
|
||||
(def, mctx)
|
||||
}
|
||||
@ -886,7 +887,7 @@ impl<'a> Generator<'a> {
|
||||
let def = ctx
|
||||
.macros
|
||||
.get(name)
|
||||
.ok_or_else(|| CompileError::from(format!("macro {:?} not found", name)))?;
|
||||
.ok_or_else(|| CompileError::from(format!("macro {name:?} not found")))?;
|
||||
(def, ctx)
|
||||
}
|
||||
};
|
||||
@ -902,7 +903,7 @@ impl<'a> Generator<'a> {
|
||||
let mut is_first_variable = true;
|
||||
for (i, arg) in def.args.iter().enumerate() {
|
||||
let expr = args.get(i).ok_or_else(|| {
|
||||
CompileError::from(format!("macro {:?} takes more than {} arguments", name, i))
|
||||
CompileError::from(format!("macro {name:?} takes more than {i} arguments"))
|
||||
})?;
|
||||
|
||||
match expr {
|
||||
@ -1089,7 +1090,7 @@ impl<'a> Generator<'a> {
|
||||
(Some(cur_name), None) => (cur_name, 0),
|
||||
// A block definition contains a block definition of the same name
|
||||
(Some(cur_name), Some((prev_name, _))) if cur_name == prev_name => {
|
||||
return Err(format!("cannot define recursive blocks ({})", cur_name).into());
|
||||
return Err(format!("cannot define recursive blocks ({cur_name})").into());
|
||||
}
|
||||
// A block definition contains a definition of another block
|
||||
(Some(cur_name), Some((_, _))) => (cur_name, 0),
|
||||
@ -1108,7 +1109,7 @@ impl<'a> Generator<'a> {
|
||||
let (ctx, def) = heritage.blocks[cur.0].get(cur.1).ok_or_else(|| {
|
||||
CompileError::from(match name {
|
||||
None => format!("no super() block found for block '{}'", cur.0),
|
||||
Some(name) => format!("no block found for name '{}'", name),
|
||||
Some(name) => format!("no block found for name '{name}'"),
|
||||
})
|
||||
})?;
|
||||
|
||||
@ -1193,7 +1194,7 @@ impl<'a> Generator<'a> {
|
||||
let id = self.named;
|
||||
self.named += 1;
|
||||
|
||||
buf_expr.write(&format!("expr{} = ", id));
|
||||
buf_expr.write(&format!("expr{id} = "));
|
||||
buf_expr.write("&");
|
||||
buf_expr.write(&expression);
|
||||
buf_expr.writeln(",")?;
|
||||
@ -1206,7 +1207,7 @@ impl<'a> Generator<'a> {
|
||||
}
|
||||
};
|
||||
|
||||
buf_format.write(&format!("{{expr{}}}", id));
|
||||
buf_format.write(&format!("{{expr{id}}}"));
|
||||
size_hint += 3;
|
||||
}
|
||||
}
|
||||
@ -1395,9 +1396,9 @@ impl<'a> Generator<'a> {
|
||||
name, self.input.escaper
|
||||
));
|
||||
} else if crate::BUILT_IN_FILTERS.contains(&name) {
|
||||
buf.write(&format!("::askama::filters::{}(", name));
|
||||
buf.write(&format!("::askama::filters::{name}("));
|
||||
} else {
|
||||
buf.write(&format!("filters::{}(", name));
|
||||
buf.write(&format!("filters::{name}("));
|
||||
}
|
||||
|
||||
self._visit_args(buf, args)?;
|
||||
@ -1601,7 +1602,7 @@ impl<'a> Generator<'a> {
|
||||
}
|
||||
_ => return Err("loop.cycle(…) expects exactly one argument".into()),
|
||||
},
|
||||
s => return Err(format!("unknown loop method: {:?}", s).into()),
|
||||
s => return Err(format!("unknown loop method: {s:?}").into()),
|
||||
},
|
||||
left => {
|
||||
match left {
|
||||
@ -1658,7 +1659,7 @@ impl<'a> Generator<'a> {
|
||||
right: &Expr<'_>,
|
||||
) -> Result<DisplayWrap, CompileError> {
|
||||
self.visit_expr(buf, left)?;
|
||||
buf.write(&format!(" {} ", op));
|
||||
buf.write(&format!(" {op} "));
|
||||
self.visit_expr(buf, right)?;
|
||||
Ok(DisplayWrap::Unwrapped)
|
||||
}
|
||||
@ -1733,12 +1734,12 @@ impl<'a> Generator<'a> {
|
||||
}
|
||||
|
||||
fn visit_str_lit(&mut self, buf: &mut Buffer, s: &str) -> DisplayWrap {
|
||||
buf.write(&format!("\"{}\"", s));
|
||||
buf.write(&format!("\"{s}\""));
|
||||
DisplayWrap::Unwrapped
|
||||
}
|
||||
|
||||
fn visit_char_lit(&mut self, buf: &mut Buffer, s: &str) -> DisplayWrap {
|
||||
buf.write(&format!("'{}'", s));
|
||||
buf.write(&format!("'{s}'"));
|
||||
DisplayWrap::Unwrapped
|
||||
}
|
||||
|
||||
@ -2032,8 +2033,7 @@ impl MapChain<'_, &str, LocalMeta> {
|
||||
|
||||
fn resolve_or_self(&self, name: &str) -> String {
|
||||
let name = normalize_identifier(name);
|
||||
self.resolve(name)
|
||||
.unwrap_or_else(|| format!("self.{}", name))
|
||||
self.resolve(name).unwrap_or_else(|| format!("self.{name}"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ impl TemplateInput<'_> {
|
||||
// of `ext` is merged into a synthetic `path` value here.
|
||||
let source = source.expect("template path or source not found in attributes");
|
||||
let path = match (&source, &ext) {
|
||||
(&Source::Path(ref path), _) => config.find_template(path, None)?,
|
||||
(Source::Path(path), _) => config.find_template(path, None)?,
|
||||
(&Source::Source(_), Some(ext)) => PathBuf::from(format!("{}.{}", ast.ident, ext)),
|
||||
(&Source::Source(_), None) => {
|
||||
return Err("must include 'ext' attribute when using 'source' attribute".into())
|
||||
@ -56,7 +56,7 @@ impl TemplateInput<'_> {
|
||||
config
|
||||
.syntaxes
|
||||
.get(&s)
|
||||
.ok_or_else(|| CompileError::from(format!("attribute syntax {} not exist", s)))
|
||||
.ok_or_else(|| CompileError::from(format!("attribute syntax {s} not exist")))
|
||||
},
|
||||
)?;
|
||||
|
||||
@ -78,7 +78,7 @@ impl TemplateInput<'_> {
|
||||
}
|
||||
|
||||
let escaper = escaper.ok_or_else(|| {
|
||||
CompileError::from(format!("no escaper defined for extension '{}'", escaping))
|
||||
CompileError::from(format!("no escaper defined for extension '{escaping}'"))
|
||||
})?;
|
||||
|
||||
let mime_type =
|
||||
@ -146,7 +146,7 @@ impl FromStr for Print {
|
||||
"ast" => Ast,
|
||||
"code" => Code,
|
||||
"none" => None,
|
||||
v => return Err(format!("invalid value for print option: {}", v,).into()),
|
||||
v => return Err(format!("invalid value for print option: {v}",).into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1238,7 +1238,7 @@ pub(crate) fn parse<'a>(
|
||||
match parse_template(src, &state) {
|
||||
Ok((left, res)) => {
|
||||
if !left.is_empty() {
|
||||
Err(format!("unable to parse template:\n\n{:?}", left).into())
|
||||
Err(format!("unable to parse template:\n\n{left:?}").into())
|
||||
} else {
|
||||
Ok(res)
|
||||
}
|
||||
@ -1251,7 +1251,7 @@ pub(crate) fn parse<'a>(
|
||||
|
||||
let source_after = match source_after.char_indices().enumerate().take(41).last() {
|
||||
Some((40, (i, _))) => format!("{:?}...", &source_after[..i]),
|
||||
_ => format!("{:?}", source_after),
|
||||
_ => format!("{source_after:?}"),
|
||||
};
|
||||
|
||||
let (row, last_line) = source_before.lines().enumerate().last().unwrap();
|
||||
|
@ -9,7 +9,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
@ -56,8 +56,7 @@ where
|
||||
fmt,
|
||||
escaper: &self.escaper
|
||||
},
|
||||
"{}",
|
||||
t
|
||||
"{t}"
|
||||
),
|
||||
DisplayValue::Safe(ref t) => t.fmt(fmt),
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.11.2", path = "../askama", default-features = false, features = ["with-gotham", "mime", "mime_guess"] }
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.11.2", path = "../askama", default-features = false, features = ["with-hyper"] }
|
||||
|
@ -43,7 +43,7 @@ async fn test_hyper() {
|
||||
server.await.expect("Could not serve");
|
||||
};
|
||||
let query = async move {
|
||||
let uri = format!("http://{}/hello/world", local_addr)
|
||||
let uri = format!("http://{local_addr}/hello/world")
|
||||
.parse()
|
||||
.expect("Could not format URI");
|
||||
let client = Client::new();
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.11.2", path = "../askama", default-features = false, features = ["with-mendes", "mime", "mime_guess"] }
|
||||
|
@ -71,8 +71,8 @@ impl From<mendes::Error> for Error {
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::Askama(e) => write!(f, "{}", e),
|
||||
Error::Mendes(e) => write!(f, "{}", e),
|
||||
Error::Askama(e) => write!(f, "{e}"),
|
||||
Error::Mendes(e) => write!(f, "{e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.11.2", path = "../askama", default-features = false, features = ["with-rocket", "mime", "mime_guess"] }
|
||||
|
@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "askama_tide"
|
||||
version = "0.14.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
description = "Tide integration for Askama templates"
|
||||
keywords = ["markup", "template", "html", "tide", "http-types"]
|
||||
homepage = "https://github.com/djc/askama"
|
||||
|
@ -1,6 +1,5 @@
|
||||
use askama::Template;
|
||||
use async_std::prelude::*;
|
||||
use std::convert::TryInto;
|
||||
use tide::{http::mime::HTML, Body, Response};
|
||||
|
||||
#[derive(Template)]
|
||||
|
@ -10,7 +10,8 @@ repository = "https://github.com/djc/askama"
|
||||
license = "MIT OR Apache-2.0"
|
||||
workspace = ".."
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.11.2", path = "../askama", default-features = false, features = ["with-warp", "mime", "mime_guess"] }
|
||||
|
@ -3,7 +3,8 @@ name = "askama_testing"
|
||||
version = "0.1.0"
|
||||
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
rust-version = "1.58"
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
|
@ -122,8 +122,7 @@ mod filters {
|
||||
}
|
||||
// for test_nested_filter_ref
|
||||
pub fn mytrim(s: &dyn (::std::fmt::Display)) -> ::askama::Result<String> {
|
||||
let s = format!("{}", s);
|
||||
Ok(s.trim().to_owned())
|
||||
Ok(s.to_string().trim().to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,14 +311,14 @@ struct FunctionRefTemplate {
|
||||
#[test]
|
||||
fn test_func_ref_call() {
|
||||
let t = FunctionRefTemplate {
|
||||
world: |s, r| format!("world({}, {})", s, r),
|
||||
world: |s, r| format!("world({s}, {r})"),
|
||||
};
|
||||
assert_eq!(t.render().unwrap(), "Hello, world(123, 4)!");
|
||||
}
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn world2(s: &str, v: u8) -> String {
|
||||
format!("world{}{}", v, s)
|
||||
format!("world{v}{s}")
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
@ -346,7 +346,7 @@ struct FunctionTemplate;
|
||||
impl FunctionTemplate {
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn world3(&self, s: &str, v: u8) -> String {
|
||||
format!("world{}{}", s, v)
|
||||
format!("world{s}{v}")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user