Skip to contents

Processes a section of a document by either rendering a template with data or including raw content. Used for building modular documents from templates and includes.

Usage

process_section(section, data, template_dir = "template-files")

Arguments

section

A list containing section configuration with elements:

  • name: Character string, name of the section

  • use_template: Logical, whether to use template rendering

  • content: Optional character vector of raw content (used if use_template is FALSE)

data

A list of data to be used for template rendering

template_dir

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

Value

A character vector containing the processed section content

Examples

if (FALSE) { # \dontrun{
section <- list(
  name = "introduction",
  use_template = TRUE
)
data <- list(title = "Report", date = "2024-01-01")
content <- process_section(section, data)
} # }