In short: Is there a way to manipulate RMarkdown's metadata
-list generated from the YAML header from within the following R-code chunks? To illustrate, I've tried the following:
---
title: "Untitled"
output: html_document
---
```{r}
rmarkdown::metadata$title <- "New title"
rmarkdown::metadata$title
```
This throws an error, though.
Error in rmarkdown::metadata$title <- "New title" :
Object 'rmarkdown' not found
Background
I'm working on a RMarkdown TeX-template. Some parts of the preamble need to be localized depending on the variable lang
defined in the YAML header. My current approach is to check the value of metadata$lang
and create a list of corresponding terms. I wanted to add the contents of the list to metadata
and access the terms in the TeX-template via $loc_wordcount$
, for example.