mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
Merge pull request #426 from Kijewski/pr-ensure_no_named_arguments
generator: fix `ensure_no_named_arguments()` test
This commit is contained in:
commit
73ba176ad5
@ -896,7 +896,7 @@ fn ensure_no_named_arguments(
|
|||||||
node: Span<'_>,
|
node: Span<'_>,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if is_argument_placeholder(arg) {
|
if let Expr::NamedArgument(..) = &**arg {
|
||||||
return Err(ctx.generate_error(
|
return Err(ctx.generate_error(
|
||||||
format_args!(
|
format_args!(
|
||||||
"`{}` filter cannot accept named arguments",
|
"`{}` filter cannot accept named arguments",
|
||||||
|
17
testing/tests/ui/custom-filter-with-named-arg.rs
Normal file
17
testing/tests/ui/custom-filter-with-named-arg.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use askama::Template;
|
||||||
|
|
||||||
|
mod filters {
|
||||||
|
use askama::Values;
|
||||||
|
|
||||||
|
pub fn do_nothing<'a>(s: &'a str, _: &dyn Values) -> askama::Result<&'a str> {
|
||||||
|
Ok(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(source = r#"{{ a | do_nothing(absolutely = "nothing") }}"#, ext = "txt")]
|
||||||
|
struct CustomFiltersCannotTakeNamedArguments<'a> {
|
||||||
|
a: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
7
testing/tests/ui/custom-filter-with-named-arg.stderr
Normal file
7
testing/tests/ui/custom-filter-with-named-arg.stderr
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
error: `do_nothing` filter cannot accept named arguments
|
||||||
|
--> CustomFiltersCannotTakeNamedArguments.txt:1:3
|
||||||
|
"a | do_nothing(absolutely = \"nothing\") }}"
|
||||||
|
--> tests/ui/custom-filter-with-named-arg.rs:12:21
|
||||||
|
|
|
||||||
|
12 | #[template(source = r#"{{ a | do_nothing(absolutely = "nothing") }}"#, ext = "txt")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
Loading…
x
Reference in New Issue
Block a user