Skip to contents

Generates document content from sections and data, then writes it to a file. This function combines document generation with file output handling and error management.

Usage

build_typst_file(sections, data, output_file, template_dir = "template-files")

Arguments

sections

List of section configurations. Each section should be a list containing:

  • name: Character string, name of the section

  • use_template: Logical, whether to use template rendering

  • content: Optional character vector of raw content

  • include: Optional logical indicating whether to include the section

data

List of data to be used in template rendering

output_file

Character string specifying the path to the output file

template_dir

Character string specifying the directory containing templates. Defaults to "template-files".

Value

Logical indicating success (TRUE) or failure (FALSE)

Examples

if (FALSE) { # \dontrun{
sections <- list(
  list(name = "header", use_template = TRUE),
  list(name = "body", use_template = TRUE)
)
data <- list(title = "Report", content = "Main content")
success <- build_typst_file(sections, data, "output.txt")
} # }