Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook template variables resolution #859

Open
truchi opened this issue Sep 23, 2023 · 3 comments
Open

Hook template variables resolution #859

truchi opened this issue Sep 23, 2023 · 3 comments

Comments

@truchi
Copy link

truchi commented Sep 23, 2023

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 deref function to the template engine, and just give the openapi.yaml entry as the context. Simple, but has the drawback that the template is not agnostic from the input (deref calls in the templates must be updated after using/unusing $ref in 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!

@Keats
Copy link
Owner

Keats commented Sep 23, 2023

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
Copy link
Author

truchi commented Sep 23, 2023

Noted. Thanks.

@truchi
Copy link
Author

truchi commented Sep 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants