tera
tera copied to clipboard
Allow runtime creation of `Function`s and `Filter`s by relaxing type parameters
Currently, functions and filters have to be 'static:
pub fn register_function<F: Function + 'static>(
&mut self,
name: &str,
function: F
)
This prevents you from generating an arbitrary number of functions at runtime.
Functions and Filters don't need to be 'static, they only need to live as long as the Tera instance they are attached to.
Currently, you can workaround this using unsafe { std::mem::transmute(...) } to get a 'static lifetime.
I'm not too fussed if you don't want this implemented, let me know what you think!
I can't remember why its using 'static tbh I wouldn't change it in the current version but we can add it to the https://github.com/Keats/tera/issues/637 list