The boilerplate package is designed to manage and
generate standardised text for scientific reports. It uses a unified
database architecture with a hierarchical path system and template
variable substitution.
The package uses a unified database structure where all content types share a common interface:
boilerplate_db (unified)
├── methods/
│   ├── statistical/
│   │   ├── regression/
│   │   └── longitudinal/
│   └── sampling/
├── measures/
│   ├── psychological/
│   └── demographic/
├── results/
├── discussion/
├── appendix/
└── template/Content is organised using dot notation paths:
# Access nested content
"methods.statistical.regression.linear"
"measures.psychological.anxiety.gad7"
"results.descriptive.demographics"get_nested_folder()
traverses the hierarchymodify_nested_entry()
adds/updates/removes entriesmethods.statistical.*
matches all statistical methodsboilerplate_path_exists()
checks path validityDynamic content substitution using {{variable}}
syntax:
# Template text
"We analysed {{n}} participants using {{method}} regression."
# Variables
list(n = 100, method = "linear")
# Result
"We analysed 100 participants using linear regression."R/
├── Core Functions
│   ├── init-functions.R          # Database initialisation
│   ├── import-export-functions.R # I/O operations
│   └── utilities.R               # Core utilities
│
├── User Interface
│   ├── manage-measures.R         # Measure management
│   ├── generate-text.R           # Text generation
│   └── generate-measures.R       # Measure generation
│
├── Data Operations
│   ├── merge-databases.R         # Database merging
│   ├── path-operations.R         # Path manipulation
│   └── category-helpers.R        # Category extraction
│
├── Format Support
│   ├── json-support.R            # JSON operations
│   ├── migration-utilities.R     # Format migration
│   └── bibliography-support.R    # Citation handling
│
└── Batch Operations
    ├── boilerplate_batch_edit_functions.R
    └── boilerplate_standardise_measures.Rboilerplate_init()
    ├── Creates directory structure
    ├── Initialises empty databases
    └── Saves as unified.json/rdsExternal Data → boilerplate_import()
    ├── Detects format (JSON/RDS/CSV)
    ├── Validates structure
    ├── Merges with existing
    └── Updates unified databaseboilerplate_generate_text()
    ├── Load unified database
    ├── Extract category paths
    ├── Apply template variables
    ├── Handle text overrides
    └── Return formatted textdefault-databases.Rdetect_database_type()list(
  methods = list(
    category1 = list(
      entry1 = list(
        text = "Method description with {{variables}}",
        reference = "@citation2023",
        keywords = c("keyword1", "keyword2")
      )
    )
  ),
  measures = list(
    category1 = list(
      measure1 = list(
        name = "measure_name",
        description = "Description",
        type = "continuous|categorical|ordinal|binary",
        ...
      )
    )
  ),
  template = list(
    global = list(var1 = "value1"),
    methods = list(var2 = "value2")
  )
)tests/testthat/
├── test-init-functions.R      # Initialisation tests
├── test-import-export.R       # I/O operations
├── test-generate-text.R       # Text generation
├── test-path-operations.R     # Path system
├── test-json-support.R        # JSON functionality
└── test-utilities.R           # Core utilities