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

[feature] Make the jinja2 Templates import/include load path consistent with the normal profile include load path #17431

Closed
1 task done
todorico opened this issue Dec 9, 2024 · 3 comments · Fixed by #17432
Assignees
Milestone

Comments

@todorico
Copy link

todorico commented Dec 9, 2024

What is your suggestion?

To illustrate the issue, let's consider the following profile hierarchy:

profiles/
    subdirA/profileA
    subdirB/profileB

If I want to include profileA in profileB, it is currently impossible to do so using Jinja syntax because the import paths seem to be relative to the current profile. For example:

In profileB:

{% include "subdirA/profileA" %} # Not Working
{% import "subdirA/profileA" as vars %} # Not Working

However, if I use the following syntax, it works because the import path is relative to the root profiles directory:

include(subdirA/profileA) # Working

Currently, it is not possible to import the profile from a neighboring directory using Jinja syntax. Would it be possible to allow Jinja templates to be loaded from the root profiles directory? This change would provide greater flexibility in organizing my profiles.

Perhaps the following function could be useful: Jinja2 FileSystemLoader.

Thank you for considering this enhancement!

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @todorico

Thanks for your suggestion.

I am trying to implement it in #17432, I think it might be doable, but we need to double check it won't be breaking other users.

@todorico
Copy link
Author

Awesome, I really appreciate your effort! 😄

@memsharded
Copy link
Member

#17432 merged, this will be in next Conan 2.11, thanks for the feedback!

@memsharded memsharded added this to the 2.11.0 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants