Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.43k stars 279 forks source link

Hook template variables resolution #859

Open truchi opened 11 months ago

truchi commented 11 months ago

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:

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!

Keats commented 11 months ago

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

truchi commented 11 months ago

Noted. Thanks.

truchi commented 11 months ago

Note: it's not even possible to implement deref since pub fn register_function<F: Fn(...) -> ... + 'static>.