Skip to contents

Rename a rendered file with YAML front matter metadata

Usage

rename_rendered(file, callback)

Arguments

file

A string that gives the path to the file to rename. Should be the result of render() in order to have metadata attached.

callback

A function that gets the rendered R Markdown YAML front matter metadata as an argument, and returns a new name for file. Any changes implied to the directory or file extension are ignored -- only the name is changed.

Value

A string that gives the path to the renamed file.

See also

render() for creating an object to use as the file argument.

Examples

if (FALSE) {
# Make sure to use rmdmatter's render() to have metadata available
output_file <- rmdmatter::render(input_file)
rename_rendered(output_file, function(metadata) {
  with(metadata, paste(title, "by", author, "on", date))
})
}