You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/blog/posts/2025-xx-xx-R-package-release-1.5/index.qmd
+15-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -33,28 +33,31 @@ Major features in this release include:
33
33
34
34
## Pass R Values to Quarto Metadata
35
35
36
-
Set metadata dynamically based on R computations with `write_yaml_metadata_block()`:
36
+
Set metadata dynamically based on R computations with `write_yaml_metadata_block()`. For example, you could check a parameter value, and conditionally include content based on it:
37
37
38
-
```{r}
39
-
#| eval: false
40
-
#| echo: fenced
38
+
```r
41
39
#| output: asis
42
-
# Compute values dynamically
43
-
debug_mode <- Sys.getenv("DEBUG") == "TRUE"
44
40
45
-
# Write metadata block
46
41
write_yaml_metadata_block(
47
-
debug_mode = debug_mode,
48
-
generated_at = Sys.Date()
42
+
is_france=params$country=="france"
49
43
)
50
44
```
51
45
46
+
This will write the following (e.g., when `quarto render report.qmd -P country:france`):
47
+
````yaml
48
+
---
49
+
is_france: true
50
+
---
51
+
````
52
+
52
53
Then use Quarto's conditional features:
53
54
54
55
```markdown
55
-
::: {.content-visible when-meta="debug_mode"}
56
-
## Debug Information
57
-
This section only appears when debug mode is enabled.
56
+
::: {.content-visible when-meta="is_france"}
57
+
## Fun fact about France
58
+
59
+
In 2025, France is the most visited country in the world, attracting over 89 million tourists annually!
0 commit comments