Replies: 1 comment 5 replies
-
I could implement use std::sync::Mutex;
use minijinja::{render, value::Value};
fn main() {
let mut counter = 0;
let rv = render!(
"{% for x in range(3) %}{{ f() }}{% endfor %}",
f => Value::from_function(Mutex::new(move || {
counter += 1;
counter
})),
);
assert_eq!(rv, "123");
} But it would still require that function to be |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know that using mutable functions at templates may sound like a bad idea, but it is what it is.
Is that possible without too much tinkering with generics?
FnMut
cannot currently be passed toadd_function
.Beta Was this translation helpful? Give feedback.
All reactions