Adding a template#
For a text-oriented generated file:
Add a Jinja template under
src/rs_files_templates/templates/.Add a model in its own
models/<template>.pymodule, derived withrsm_template_base()from the smallest useful set ofRSMMetadatafields.Set
template_name,output_name, and, when applicable,schema_urlandmedia_type.Reuse nested models from
rsm_schema.generated. Put cross-template normalization helpers inmodels/utils.py.Add rendering tests and a schema-backed test when the output format publishes a schema.
Add the model to the public package exports.
Keep complex transformations in the per-template model. Jinja should make the output structure obvious and primarily decide layout and optional sections.
Bundling several files into one archive#
Some targets (such as GitHub issue forms) require several files at fixed relative paths, so the platform reads them as a group. Render this as one archive model instead of one model per file:
Add a Jinja template per archive member under
templates/, as usual.Set
media_type = "zip"andoutput_nameto the.zippath.Override
archive_entries()to return{member filename: rendered content}, rendering each member withrenderer.render_template(template_name, data).Leave
template_namepointing at the primary (or first) member template for documentation;render_text()is not used for archive models.
render_file() detects media_type == "zip" and writes archive_entries() as a zip instead of
writing render_text() as a single file.