Skip to content

Commit b05bcfc

Browse files
committed
Remove computation requirement
1 parent 3b1e561 commit b05bcfc

File tree

1 file changed

+15
-12
lines changed
  • docs/blog/posts/2025-xx-xx-R-package-release-1.5

1 file changed

+15
-12
lines changed

docs/blog/posts/2025-xx-xx-R-package-release-1.5/index.qmd

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,31 @@ Major features in this release include:
3333

3434
## Pass R Values to Quarto Metadata
3535

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:
3737

38-
```{r}
39-
#| eval: false
40-
#| echo: fenced
38+
```r
4139
#| output: asis
42-
# Compute values dynamically
43-
debug_mode <- Sys.getenv("DEBUG") == "TRUE"
4440

45-
# Write metadata block
4641
write_yaml_metadata_block(
47-
debug_mode = debug_mode,
48-
generated_at = Sys.Date()
42+
is_france = params$country == "france"
4943
)
5044
```
5145

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+
5253
Then use Quarto's conditional features:
5354

5455
```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!
60+
5861
:::
5962
```
6063

0 commit comments

Comments
 (0)