tera icon indicating copy to clipboard operation
tera copied to clipboard

how do i register a function?

Open Directory opened this issue 3 years ago • 3 comments

https://tera.netlify.app/docs/#functions

the docs seem outdated. this isnt valid rust i dont think.

Directory avatar Jun 21 '22 21:06 Directory

You can have a look at https://github.com/Keats/tera/blob/master/src/builtins/functions.rs for some examples of built-in functions

Keats avatar Jun 22 '22 07:06 Keats

after figuring it out ill update this issue with how instead the documentation is very vague and bad. How should anyone know that the Result type is a special wrapper and not built in. whats the Function type from? How was anyone supposed to know that serde_json is used here. The example code should be updated with all necessary imports that it uses. Additionally i think it would be a better example if instead it was a tera::Function implementation on an empty struct rather than a function that returns a Box. Considering how awful this documentation was theres probably other awful code examples in the rest of the docs.

Directory avatar Jun 29 '22 00:06 Directory

Sorry for the awful documentation. Have you seen the awful API documentation as well on https://docs.rs/tera/latest/tera/trait.Function.html? That should answer some of your questions.

Keats avatar Jun 29 '22 09:06 Keats