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: vignettes/dynamic-metadata.qmd
+90Lines changed: 90 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,96 @@ Generated at: {{< meta generated_at >}}
93
93
This content would be hidden when debug mode is enabled.
94
94
:::
95
95
96
+
## Advanced Use Case: Email Variant Testing
97
+
98
+
One powerful application of dynamic metadata is variant emails using Quarto's email format. This example shows how to randomly select an email variant and conditionally display different content based on that selection:
This example demonstrates several advanced concepts:
179
+
180
+
1.**Random variant selection**: Using `sample()` to randomly choose one of three email variants
181
+
2.**Dynamic metadata generation**: Creating boolean metadata flags for each variant using `sprintf()` and `setNames()`
182
+
3.**Conditional email content**: Each variant shows different content (different datasets, subjects) based on the selected metadata flag
183
+
4.**Email-specific features**: Using Quarto's email format with `.subject` divs and `.email-scheduled` metadata
184
+
5.**Logging and tracking**: Recording which variant was selected for analysis purposes
185
+
96
186
## Technical Details
97
187
98
188
The `write_yaml_metadata_block()` function generates a YAML metadata block that can be inserted into the document body. It accepts named arguments or a list, which are converted to YAML format. The **yaml** R package is used for YAML serialization: <https://github.com/vubiostat/r-yaml>
0 commit comments