wch / webshot

Take screenshots of web pages from R
http://wch.github.io/webshot/
227 stars 40 forks source link

rmdshot override params in render function #120

Closed RKonstantinR closed 1 year ago

RKonstantinR commented 1 year ago

There is a way to set custom parameters in "rmdshot" with "rmd_args" that override params specified within the YAML front-matter rmd or quarto document?

Repex:

quarto doc:

---
title: "repex_rmdshot"
format: html
editor: visual
params: 
    col_name: "cyl"
---

```{r}
library(dplyr)

mtcars %>% select(params$col_name)
### R script

library(webshot)

webshot::rmdshot("repex_rmdshot.qmd", rmd_args = list(col_name = "mpg"), file = here::here("test.png"))


## My code is giving me an error:

Error in (function (input, output_format = NULL, output_file = NULL, output_dir = NULL, : unused argument (col_name = "mpg")

RKonstantinR commented 1 year ago

I'm sorry I figured it out. webshot::rmdshot("repex_rmdshot.qmd", rmd_args = list(params = list(col_name = "mpg")), file = here::here("test.png"))