write_source | R Documentation |
These functions write one or more source(s) from memory (as
loaded by load_source()
or load_sources()
to a file.
write_source( x, output, encoding = rock::opts$get("encoding"), preventOverwriting = rock::opts$get("preventOverwriting"), silent = rock::opts$get("silent") ) write_sources( x, output, filenamePrefix = "", filenameSuffix = "_written", encoding = rock::opts$get("encoding"), silent = rock::opts$get("silent") )
x |
The source(s). |
output |
The filename (for |
encoding |
The encoding to use. |
preventOverwriting |
Whether to prevent against overwriting of the
file(s) to write. Set to |
silent |
Whether to be chatty or quiet. |
filenamePrefix, filenameSuffix |
Optional prefixes or suffixes to pre- or append to the filenames when writing the files. |
Invisibly, the input (x
), to enable chaining in pipes.
### Get path to example source examplePath <- system.file("extdata", package="rock"); ### Get a path to one example file exampleFile <- file.path(examplePath, "example-1.rock"); ### Get a temporary file to write to tempFile <- tempfile(fileext = ".rock") ### Pipe chain to load the example source; add a code; ### and write the result to disk loadedSource <- rock::load_source(exampleFile) |> rock::code_source(c("Lorem Ipsum" = "lorumIpsum")) |> rock::write_source(tempFile);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.