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

nested source is incorrect #520

Open
xenoterracide opened this issue Feb 3, 2025 · 2 comments
Open

nested source is incorrect #520

xenoterracide opened this issue Feb 3, 2025 · 2 comments
Labels

Comments

@xenoterracide
Copy link

Describe the bug

if doing multiple nested includes the {{ yadm.source }} will be incorrect past the first level

To reproduce

# /home/xeno/.config/yadm/alt/.zshrc##template,e.zsh
{% include "../extra/zshrc.os.{{ yadm.os }},e.zsh" %}

in our os file

{% include "../extra/vim##class.{{ yadm.class }},e.zsh" %}

in the vim file

# START: {{ yadm.source }}

OUTPUT

# START: /home/xeno/.config/yadm/alt/.zshrc##template,e.zsh

Expected behavior

# START: /home/xeno/.config/yadm/alt/../extra/vim##class.,e.zsh

note: I put nothing between the . and the , because it would be an empty string if no class is set

Environment

bash version 5.2.37(1)-release
 git version 2.47.1
yadm version 3.3.0

Additional context

[Add any other context about the problem here.]

@erijo
Copy link
Collaborator

erijo commented Feb 3, 2025

The question is if this is a bug or not. The documentation states:

During processing, the following variables are available in the template:

Default              Jinja or ESH         Description
-------------        -------------        ----------------------------
...
yadm.source          YADM_SOURCE          Template filename

Guess it boils down to if the "template" is the original template file or any included file. For the default template processor it would be possible to update yadm.source when including files, but for the others it wouldn't work. So I'm leaning towards the current behavior being the correct. But I'm interesting to hear if you have some other view on it?

@xenoterracide
Copy link
Author

xenoterracide commented Feb 4, 2025

I definitely have another view, because when you get over 2 templates deep it becomes more challenging to find out where code came from in the final result. also if you're using SPDX snippets you might have a licenses that is different from aggregated file. I guess I kind of expect it to work similar to a location in a logger, printing the correct class/file; without the line number in this case.

I speculate that the description and variable name don't really match, and since a template can include a template, although it doesn't have to be a template that's included.

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

No branches or pull requests

2 participants