mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
Add regression test for moving variables in let statement
This commit is contained in:
parent
fa467172dd
commit
e7f2979b73
@ -39,7 +39,7 @@ fn test_ref_deref() {
|
|||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(
|
#[template(
|
||||||
source = r#"
|
source = r#"
|
||||||
{%- let x = *title -%}
|
{%- let x = **title -%}
|
||||||
{%- if x == "another" -%}
|
{%- if x == "another" -%}
|
||||||
another2
|
another2
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
@ -131,3 +131,23 @@ fn test_decl_assign_range() {
|
|||||||
let t = DeclAssignRange;
|
let t = DeclAssignRange;
|
||||||
assert_eq!(t.render().unwrap(), "1");
|
assert_eq!(t.render().unwrap(), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(
|
||||||
|
source = "
|
||||||
|
{%- set t = title -%}
|
||||||
|
{{t}}/{{title -}}
|
||||||
|
",
|
||||||
|
ext = "txt"
|
||||||
|
)]
|
||||||
|
struct DoNotMoveFields {
|
||||||
|
title: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_not_moving_fields_in_var() {
|
||||||
|
let x = DoNotMoveFields {
|
||||||
|
title: "a".to_string(),
|
||||||
|
};
|
||||||
|
assert_eq!(x.render().unwrap(), "a/a");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user