This function extracts and returns the template portion of a unified database, optionally retrieving a specific template by name.
Value
List or character. The requested template database or specific template. If name is NULL, returns the entire template database. If name is specified, returns the template with that name.
Examples
# Create a temporary directory and initialise database
temp_dir <- tempdir()
data_path <- file.path(temp_dir, "boilerplate_template_example", "data")
# Initialise with default template content
boilerplate_init(
categories = "template",
data_path = data_path,
create_dirs = TRUE,
create_empty = FALSE,
confirm = FALSE,
quiet = TRUE
)
# Import all databases
unified_db <- boilerplate_import(data_path = data_path, quiet = TRUE)
# Get all templates
template_db <- boilerplate_template(unified_db)
names(template_db)
#> [1] "journal_article" "conference_presentation"
#> [3] "grant_proposal"
# Get a specific template (if it exists)
if ("template" %in% names(unified_db) && length(unified_db$template) > 0) {
template_names <- names(unified_db$template)
if (length(template_names) > 0) {
first_template <- boilerplate_template(unified_db, template_names[1])
}
}
# Clean up
unlink(file.path(temp_dir, "boilerplate_template_example"), recursive = TRUE)