The bookdown reference for SQL chunks states that:
If you need to bind the values of R variables into SQL queries, you can do so by prefacing R variable references with a ?.
But, how do you use R variables in css code chunks?
The bookdown reference for SQL chunks states that:
If you need to bind the values of R variables into SQL queries, you can do so by prefacing R variable references with a ?.
But, how do you use R variables in css code chunks?
If you want to output CSS code that affects the document, I'd use the glue package to do the substitutions, in an R code chunk that has echo=FALSE, results='asis'. For example,
```{r css, echo=FALSE, results='asis'}
margin <- 40
library(glue)
cat(glue(.open = "<<", .close = ">>", "
<style>
h1 {
margin-left: <<margin>>px;
}
</style>
"))
```
would put the parts between <style> ... </style> into your document, substituting for R variables whereever it sees a variable name in double angle brackets, e.g. <<margin>> in my example.
bs_get_variables(bslib::bs_current_theme(), "primary")