tera
tera copied to clipboard
Round filter does not return int with precision = 0
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 }) }) })