-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have a flexible quarto_get_meta()
#182
Comments
Can you give some use case and example of usage on how this would work ? Quarto does not work as R Markdown and all the meta that will be used for Pandoc rendering won't be accessible on knitting time IMO. So I want clarify what is expected here. Let's remind that Quarto has some way to read the meta : and an extensions mechanism through Lua Filters to compute on the Meta Unless we are not talking on the same metadata. Thanks |
In short, I'd like something that works 2 ways: (i.e. you set it in one place, and can use it as an r variable + quarto metadata. I would just want to be able to use it as an R variable.. The meta shortcode is useful to print things, but not to manipulate it. I don'y know anything about lua, so I'd have to dig into it to find out more.. Let's say I want to read the date. ---
title: "A title"
date: 2024-03-22
---
```{r}
month <- lubridate(ym(get_meta("date")
```
The month is `r month`
Basically, I would like to be able to set something once (either as R code OR in yaml meta) and let quarto AND R use it. Alternatively, if the following worked (I think it did in rmarkdown. ---
title: "A title"
date: 2024-03-22
---
```{r}
date <- "2024-03-22"
month <- lubridate::month(date)
```
---
date: !expr date
---
`r month`
|
This would be a feature request to Quarto itself so that metadata are accessible using objects inside computation cells. It is not just a Quarto R package feature. This 📦 is only a wrapper around quarto CLI, which additional helpers for R users. This is much more a feature that would need to work for all engine in Quarto (Jupyter, Knitr, Julia, ...) You can probably open a discussion there about this, if none exists already
This is about It works today, you just need to drop the ---
title: "A title"
---
```{r}
date <- "2024-03-22"
month <- lubridate::month(date)
```
---
date: '`r date`'
---
`r month`
|
I was sure I tried this, but it didn't work. I will browse quarto discussions / issues and link here if necessary! Note that it works for date but not for format. Thanks for the explanations. Requested in quarto-dev/quarto-cli#10886. |
to be able to program around some things in the metadata from R
accessing the yaml metadata is currently difficult
The text was updated successfully, but these errors were encountered: