R/template.R
raw| 1 | |
| 2 | renv_template_create <- function(template) { |
| 3 | gsub("^\\n+|\\n+$", "", template) |
| 4 | } |
| 5 | |
| 6 | renv_template_replace <- function(text, replacements, format = "${%s}") { |
| 7 | |
| 8 | enumerate(replacements, function(key, value) { |
| 9 | key <- sprintf(format, key) |
| 10 | text <<- gsub(key, value, text, fixed = TRUE) |
| 11 | }) |
| 12 | |
| 13 | text |
| 14 | |
| 15 | } |