Registers a reusable domain-specific study template in the session template
registry. Every candidate template is strictly gated by both
assert_valid_spec_ir() and verify_compiled_r_ast() on its compiled R
script before registration succeeds, ensuring no invalid or unsafe template
can enter the registry. Built-in templates cannot be overwritten.
Usage
register_spec_template(
name,
spec,
description = NULL,
category = "custom",
overwrite = FALSE
)Arguments
- name
Character scalar template name (must be a valid ASCII R identifier matching
^[A-Za-z][A-Za-z0-9_]*$).- spec
A valid
spec_irobject.- description
Optional plain-language template description.
- category
Character scalar category label (default
"custom").- overwrite
Logical; whether to replace an existing custom template of the same name (default
FALSE).
Examples
my_spec <- new_spec_ir(
title = "Small Pilot OLS",
design_type = "monte_carlo_lm",
hierarchy = list(levels = 1L, n_obs = 80L)
)
register_spec_template("pilot_ols_ex", my_spec, description = "80-unit OLS pilot")
s <- use_spec_template("pilot_ols_ex", n_obs = 120L)
s$hierarchy$n_obs
#> [1] 120
unregister_spec_template("pilot_ols_ex")
