Skip to contents

This function creates a new 'Quarto' document (.qmd file) with either a custom or standard YAML header. When using a custom header, it integrates with `froggeR::settings()` for reusable metadata across documents.

Usage

write_quarto(
  filename = "frogs",
  path = here::here(),
  custom_yaml = TRUE,
  .initialize_proj = FALSE
)

Arguments

filename

Character string. The name of the file without the '.qmd' extension. Only letters, numbers, hyphens, and underscores are allowed.

path

Character string. Path to the project directory.

custom_yaml

Logical. If TRUE (default), creates a 'Quarto' document with a custom YAML header using values from `_variables.yml`. If FALSE, creates a standard 'Quarto' document.

.initialize_proj

Logical. TRUE only if starting a froggeR::quarto_project().

Value

Invisibly returns NULL after creating the 'Quarto' document.

Details

When `custom_yaml = TRUE`, the function will check if `_variables.yml` exists. This file is needed to supply Quarto document metadata in the `path` project. The user will be prompted with help if they don't already exist, and a Quarto document with the default template will be supplied instead.

Examples

# Create a temporary directory for testing
tmp_dir <- tempdir()

# Write the Quarto & associated files for a custom YAML with reusable metadata
write_quarto(path = tempdir(), filename = "frog_analysis")
#>  No project-level or global settings file found.
#>  Created _variables.yml
#>  Created _quarto.yml
#>  Created custom.scss
#>  Created frog_analysis.qmd with custom YAML

# Write the Quarto file with a template requiring more DIY
write_quarto(path = tempdir(), filename = "frog_analysis_basic", custom_yaml = FALSE)
#>  Created frog_analysis_basic.qmd 

# Confirm the file was created (optional, for user confirmation)
file.exists(file.path(tmp_dir, "frog_analysis.qmd"))
#> [1] TRUE
file.exists(file.path(tmp_dir, "frog_analysis_basic.qmd"))
#> [1] TRUE

# Clean up: Remove the created file
unlink(list.files(tempdir(), full.names = TRUE), recursive = TRUE)