Skip to content

Generate file structures on dynamic loop #1271

@yajo

Description

@yajo

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions