Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round filter does not return int with precision = 0 #889

Open
jasger9000 opened this issue Jan 12, 2024 · 0 comments
Open

Round filter does not return int with precision = 0 #889

jasger9000 opened this issue Jan 12, 2024 · 0 comments
Labels

Comments

@jasger9000
Copy link

When using the | round filter with precision = 0 to return a natural number, the filter still returns a float leading to unexpected behavior when using it in combination with functions expecting an integer.

Minimal code that does not work

use tera::{Tera, Context};

fn main() {
    let test = Tera::one_off(
        "{% for i in range(end=5.5 | round) %} {{ i }}\n {% endfor %}",
        &Context::new(),
        true
    );

    print!("{test:?}");
}

Output

Err(Error { kind: Msg("Failed to render '__tera_one_off'"), source: Some(Error { kind: CallFunction("range"), source: Some(Error { kind: Msg("Function range received end=6.0 but end can only be a number"), source: None }) }) })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants