Modify all variables in files from the book skeleton
prepare_files( path, replacements = c(book_title = "My book", author_name = "Marion Louveaux", creation_date = "`r Sys.Date()`", short_description = "An example of book with {bookprep}.", index_title = "Context"), pattern = "[.]Rmd$|[.]yml$|[.]md$" )
path | path to directory (skeleton) containing all files to modify |
---|---|
replacements | a vector of correspondences between an input and an output. Input is fixed and corresponds to: book_title, author_name, creation_date, short_description and index_title |
pattern | regex to identify files to prepare (by default, all Rmd, yml and md files) |
path from each modified file
# Create temporary directory for reproducible example dir_tmp <- tempfile(pattern = "proj-") dir.create(dir_tmp) # browseURL(dir_tmp) # prepare_files() requires a directory with some files inside to look for replacements file.copy(from = system.file("book_skeleton", package = "bookprep"), to = dir_tmp, recursive = TRUE)#> [1] TRUEbookprep:::prepare_files( path = dir_tmp, replacements = c( "book_title" = "My book", "author_name" = "Marion Louveaux", "creation_date" = "`r Sys.Date()`", "short_description" = "An example of book with {bookprep}.", "index_title" = "Context" ) )#> [1] "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmp2M91OU/proj-66cdea7101/book_skeleton/_bookdown.yml" #> [2] "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmp2M91OU/proj-66cdea7101/book_skeleton/_output.yml" #> [3] "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmp2M91OU/proj-66cdea7101/book_skeleton/index.Rmd" #> [4] "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmp2M91OU/proj-66cdea7101/book_skeleton/README.md"