Creates a file from data and a template found in a package. Provides control
over file name, the addition to
.Rbuildignore, and opening the file for
use_template( template, save_as = template, data = list(), ignore = FALSE, open = FALSE, package = "usethis" )
Path to template file relative to
Path of file to create, relative to root of active project.
A list of data passed to the template.
Should the newly created file be added to
Open the newly created file for editing? Happens in RStudio, if
applicable, or via
Name of the package where the template is found.
A logical vector indicating if file was modified.
This function can be used as the engine for a templating function in other
template argument is used along with the
to derive the path to your template file; it will be expected at
fs::path_package(package = package, "templates", template). We use
fs::path_package() instead of
base::system.file() so that path
construction works even in a development workflow, e.g., works with
pkgload::load_all(). Note this describes the
fs::path_package() in fs v220.127.116.1101 and higher.
To interpolate your data into the template, supply a list using
data argument. Internally, this function uses
whisker::whisker.render() to combine your template file with your data.