Hook template variables resolution
Hello,
I'm prototyping an OpenAPI generator with Tera (great job btw).
I am facing this issue: in OpenAPI, objects can reference other objects. To deal with this I have the option:
- To provide a
dereffunction to the template engine, and just give theopenapi.yamlentry as the context. Simple, but has the drawback that the template is not agnostic from the input (derefcalls in the templates must be updated after using/unusing$refin the yaml), - To resolve the full OpenAPI data before rendering the templates. Harder, and infinite recursion issues.
It would be ideal to have the chance to "hook" variable resolution (is that how you call it?) so dereferencing could happen automagically in the templates.
Is that something that I can do with Tera currently? Or how could I emulate it? Do you have broader ideas on how to tackle this issue?
Thank you!
We don't have this concept of pointers in the data in either Tera v1 or v2. No plans to add any hook in there either
Noted. Thanks.
Note: it's not even possible to implement deref since pub fn register_function<F: Fn(...) -> ... + 'static>.