mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 23:10:54 +00:00
Add regression test to prevent moving variables
This commit is contained in:
parent
6be20d5782
commit
62bbece0aa
@ -99,3 +99,31 @@ fn test_double_attr_arg() {
|
||||
let t = DoubleAttrArg { x: (10,) };
|
||||
assert_eq!(t.render().unwrap(), "156");
|
||||
}
|
||||
|
||||
// Ensures that fields are not moved when calling a jinja macro.
|
||||
#[derive(Template)]
|
||||
#[template(
|
||||
source = "
|
||||
{%- macro package_navigation(title, show) -%}
|
||||
{%- if show -%}
|
||||
{{title}}
|
||||
{%- else -%}
|
||||
no show
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- call package_navigation(title=title, show=true) -%}
|
||||
",
|
||||
ext = "html"
|
||||
)]
|
||||
struct DoNotMoveFields {
|
||||
title: String,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_do_not_move_fields() {
|
||||
let x = DoNotMoveFields {
|
||||
title: "a".to_string(),
|
||||
};
|
||||
assert_eq!(x.render().unwrap(), "a");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user