Find and replace all variables in one of the files of the book skeleton

find_and_replace(
  file,
  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")
)

Arguments

file

path of a file from skeleton: _bookdown.yml, _output.yml, index.Rmd, README.md

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

Value

path of the modified file

Examples

# copy to a temporary file to avoid overwriting the package index_tmp <- tempfile(pattern = "index-") file.copy(from = system.file("book_skeleton/index.Rmd", package = "bookprep"), to = index_tmp)
#> [1] TRUE
bookprep:::find_and_replace( file = index_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] "/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/Rtmp2M91OU/index-66c383c6143"