tera icon indicating copy to clipboard operation
tera copied to clipboard

Make it easer to have functions/filters take rust types

Open WesleyAC opened this issue 3 years ago • 2 comments

Currently, custom functions and filters must take dynamic values. However, it would be nice to be able to register filters and functions that take and return any rust type that implements Serialize/Deserialize, and have tera deal with doing the conversion.

WesleyAC avatar Jan 17 '22 09:01 WesleyAC

@Keats did you start any work on this yet? I have implemented this feature for https://github.com/yarn-slinger/yarn-slinger recently and am thinking about implementing it in tera for Hacktober :)

For reference, this book shows how the trick is done.

janhohenheim avatar Sep 26 '23 14:09 janhohenheim

IT is not implemented yet in v2: https://github.com/Keats/tera2

The main issue (afaik) to use actual types is that Tera uses keyword arguments rather than positional. I didn't dig into it yet but I wasn't sure how to handle that

Keats avatar Sep 26 '23 19:09 Keats