Description Usage Arguments Details Value Examples
View source: R/export_template.R
This is a simple wrapper function around as_utf8
and
writeLines
, letting users write their template strings
to file without having to worry about file encodings. For more details on
why UTF-8 encoding is necessary, check out
Yihui Xie's post
on the subject.
1 2 3 4 5 6 7 | export_template(
template,
filename,
sep = "",
filename.is.string = TRUE,
strip.carriage.returns = TRUE
)
|
template |
The template string to be written out |
filename |
The path to write the template to, passed to
|
sep |
Separator to use between lines written, passed to
|
filename.is.string |
A logical value indicating whether or not the filename parameter is expected to be a string (that is, a character vector). Setting the value to FALSE disables the warning when a non-character argument is passed, but this is unsupported functionality. |
strip.carriage.returns |
A logical value indicating whether or not to
strip carriage feed characters, should any exist. This
preserves line spacing when writing out files originally written on Windows;
otherwise |
Note that this function is effectively the inverse of
import_pattern
–
export_template(import_pattern("out.txt"), "out.txt")
should
always result in an unchanged file, and exceptions to this rule would be
considered bugs.
Returns the input template invisibly.
1 2 | pattern_file <- tempfile("out", tempdir(), ".Rmd")
export_template("my sample pattern", pattern_file)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.