copier icon indicating copy to clipboard operation
copier copied to clipboard

Generate file structures on dynamic loop

Open yajo opened this issue 1 year ago • 1 comments

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 https://github.com/copier-org/copier/discussions/908#discussioncomment-6543747

yajo avatar Jul 26 '23 05:07 yajo

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?

0xsoydev avatar Aug 07 '23 14:08 0xsoydev