Skip to content

Allow cookiecutter to create single files (rather than directories). #153

@khorn

Description

@khorn

Cookie cutter currently requires a top level directory to be present in the cookiecutter "template". This is great for the use case of generating project templates, but cookiecutter could also be a useful tool for generating individual files.

One example might be generating RestructuredText/Markdown files with automated metadata for static site generators. Or salt configuration files.

So your cookiecutter template might look something like:

C:.
└───pelican_post_cookiecutter
        cookiecutter.json
        {{ cookiecutter.title }}.rst

Then you switch to the appropriate directory, run the cookiecutter and have a new blog post file, ready for editing, with metadata (author, post date, whatever) already in place.

There would probably need to be a config var in cookiecutter.json that could specify the "root" file/directory for a cookiecutter template, with {{ cookiecutter.repo_name }}/ being the default.

Something like:

{
    "__root__": "{{ cookiecutter.title }}.rst"
}

for the example structure given above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions