Skip to content

Extra {} blocks are harmful for argument passing #683

@GuillaumeGomez

Description

@GuillaumeGomez

Can be reproduced with this code:

use askama::Template;
use std::borrow::Borrow;

pub fn bar(_: &String) -> String {
    String::new()
}

#[derive(Template)]
#[template(source = r#"
{{ crate::bar(b.to_string().borrow()) }}
"#, ext = "txt")]
struct Foo {
    b: u32,
}

Problem here is that b.to_string().borrow() is generated surrounded with {}. If you expand the code and removed the surrounding braces, code compiles just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions