Templates
This page lists jcmt2jcm and
format_jcm, the public functions for
rendering and formatting JCMsuite template files. See Templating and
Format JCM Files for usage guidance.
Public template namespace for jcmsuite.
- jcmsuite.templates.format_jcm(source, *, indent=' ')[source]
Format JCM source while preserving values and embedded Python.
- Parameters:
source (str) – Source text that contains JCM syntax and optional template Python.
indent (str, default=" ") – Text to insert for each brace nesting level. The value must not be empty.
- Returns:
Formatted source.
- Return type:
str
- Raises:
ValueError – If the source contains unbalanced braces, an unterminated string, an invalid template boundary, or an empty
indentvalue.
- jcmsuite.templates.jcmt2jcm(jcmt_file, keys=None, outputfile=None)[source]
Create a JCM file from a .jcmt or .jcmpt template.
- Parameters:
jcmt_file (str | Path) – Path to the template file. The file name must end in .jcmt or .jcmpt.
keys (Mapping[str, object] | None, optional) – Project Key values to insert into the template. Python blocks in the template can also use these values.
outputfile (str | Path | None, optional) – Path for the generated file. If omitted, the converter removes the trailing t from the template extension (.jcmt becomes .jcm and .jcmpt becomes .jcmp).
- Returns:
Absolute path of the new JCM file.
- Return type:
Path
- Raises:
InvalidConfigurationError – If the template path or extension is invalid.
TemplateMappingError – If the template contains an error. The error identifies the source position when possible.