Skip to content

cookiecutter template inheritance #409

@vaab

Description

@vaab

I'm highly interested in cookiecutter template inheritance.

It doesn't seems complicated to implement, and I might try it soon.

My first reflection is that it requires to change some core principle, although they are implementable while keeping backward compatibility.

  • use of YAML in cookiecutter.yml, adds a inherit keyword, allowance for multiple inherited value
    doesn't seem difficult to handle:
    inherit:
      cookiecutter-py: https://github.com/audreyr/cookiecutter-py
    context:
        ...
  • the name of the main template directory should not be managed as it is today. It should be a fixed name (like say 'src') and the final name of the actual created directory should be given by other means (config file probably.
    • Why ?
      • (unrelated) the current way of detecting this directory is clunky to say the least, and without good justification it seems.
      • In some ways, allowing to set the name from the template dir is somewhat awkwards, and as a result nearly every body don't use that feature and ends up with a {{cookiecutter.repo_name}} or something equivalent. As a user, I might want to specify my target directory name at the CLI level also. Today, the 'repo_name' feels that it should be a command line argument more than queried variable for more than one reason (you don't need to set it per default in your config file for instance).
      • To support inheritance, for instance, you want your 'cookiecutter-python' project to define a generic set of file. But how to name your root dir ? Your 'cookiecutter-django' template will want to override this name with 'django-{{name}}'.

Thank you for your great work on cookiecutter. Don't be offensed by my reflections. And please consider giving me a feedback on how do you feel about these ideas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions