| Title: | Generate Project Files from a Template |
|---|---|
| Description: | Generate project files and directories following a pre-made template. You can specify variables to customize file names and content, and flexibly adapt the template to your needs. 'cookiecutter' for 'R' implements a subset of the excellent 'cookiecutter' package for the 'Python' programming language (<https://github.com/cookiecutter/>), and aims to be largely compatible with the original 'cookiecutter' template format. |
| Authors: | Felix Henninger [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-7730-9511>), Aida Kreider [aut], National Research Data Infrastructure Germany, BERD Consortium [fnd] |
| Maintainer: | Felix Henninger <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-05-19 06:19:14 UTC |
| Source: | https://github.com/felixhenninger/cookiecutter |
This function takes a cookiecutter-compatible template directory and resolves template placeholders in both filenames and (for text files) content.
bake( template, output_path, extra_context = list(), overwrite = FALSE, no_input = FALSE )bake( template, output_path, extra_context = list(), overwrite = FALSE, no_input = FALSE )
template |
Template to apply |
output_path |
Directory to fill |
extra_context |
Context variables to use while populating template |
overwrite |
Whether to overwrite existing files |
no_input |
Don't prompt for context variables specified in cookiecutter.json |
template
Path to the template to apply. This can point to either a directory, or an
archive of the same in .zip, .tar or .tar.gz formats.
output_path
Path of directory to output processed template files into. This will be
filled based on the contents of the template option.
extra_context
List of template variables to use in filling placeholders. (empty by default)
overwrite
Whether to overwrite existing files. (defaults to false, and issues a
message)
no_input
Don't prompt the user for variable values specified in cookiecutter.json.
This removes the need for interaction when applying a template.
None
# Extract a demo template # (this uses a bundled template and extracts information # into a temporary directory -- you'll have it easier # because you can insert the paths you want directly) cookiecutter::bake( system.file('examples/demo.zip', package = 'cookiecutter'), fs::path_temp('cookiecutter.demo'), extra_context = list( flavor = 'chocolate chip', hot_beverage = 'coffee' ) )# Extract a demo template # (this uses a bundled template and extracts information # into a temporary directory -- you'll have it easier # because you can insert the paths you want directly) cookiecutter::bake( system.file('examples/demo.zip', package = 'cookiecutter'), fs::path_temp('cookiecutter.demo'), extra_context = list( flavor = 'chocolate chip', hot_beverage = 'coffee' ) )