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

Generate file structures on dynamic loop #1271

Open
yajo opened this issue Jul 26, 2023 · 2 comments
Open

Generate file structures on dynamic loop #1271

yajo opened this issue Jul 26, 2023 · 2 comments
Milestone

Comments

@yajo
Copy link
Member

yajo commented Jul 26, 2023

Just: {% yield single_var from looped_var %}{{ single_var }}{% endyield %}

The implementation could be similar to https://github.com/orgs/copier-org/discussions/908#discussioncomment-6505536:

Does single_var exist in context?

  • yes: do nothing special
  • no: raise YieldException("single_var", looped_var)

OK, we got the exception. Now, are you rendering a filename?

  • Yes: start loop. Inject single_var in the context and keep rendering the contents (of the dir/file, recursively).
  • No: just let the exception raise and print a nice message "Using yield outside of file names isn't supported".

Originally posted by @yajo in #908 (reply in thread)

@yajo yajo added this to the Later milestone Jul 26, 2023
@0xsoydev
Copy link

0xsoydev commented Aug 7, 2023

Hello there @yajo, I am new to the open source community, I would like to try and solve this issue, if you may, could you please assign this issue to me?

@kj-9
Copy link

kj-9 commented Nov 10, 2024

@yajo
Hi, I've created #1855 to implement the yield tag functionality. Would you kindly review and provide advice?

I'm new to Copier and don't have deep knowledge of the codebase yet, so I'm not entirely confident if this implementation is the best approach.

I'm really looking forward to having this feature available, and I hope this contribution can help move it forward. Any feedback would be greatly appreciated!

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

No branches or pull requests

3 participants