bake {cookiecutter}R Documentation

Fill a directory with files based on a cookiecutter template.

Description

This function takes a cookiecutter-compatible template directory and resolves template placeholders in both filenames and (for text files) content.

Usage

bake(
  template,
  output_path,
  extra_context = list(),
  overwrite = FALSE,
  no_input = FALSE
)

Arguments

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

Details

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.

Value

None

Examples

# 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'
  )
)


[Package cookiecutter version 0.1.0 Index]