pjkm.core.templates.renderer¶
Template renderer: wraps Copier’s run_copy / run_update for project generation.
Classes¶
Renders a Copier template to a destination directory. |
Module Contents¶
- class pjkm.core.templates.renderer.TemplateRenderer[source]¶
Renders a Copier template to a destination directory.
- render(template_path, dest, data=None, overwrite=False, skip_if_exists=None, pretend=False)[source]¶
Render a template to the destination.
- Parameters:
template_path (pathlib.Path) – Path to the Copier template directory.
dest (pathlib.Path) – Destination directory.
data (dict[str, Any] | None) – Answers to template questions (bypasses prompts).
overwrite (bool) – Whether to overwrite existing files.
skip_if_exists (list[str] | None) – File patterns to skip if they already exist.
pretend (bool) – If True, don’t actually write files.
- Return type:
None
- update(template_path, dest, data=None, pretend=False)[source]¶
Re-render a template that was previously applied to the destination.
Attempts
copier.run_updatewhich reads.copier-answers.ymlfrom dest to determine the original template. If that file is missing the caller should fall back torender()withoverwrite=True.- Parameters:
template_path (pathlib.Path) – Path to the Copier template directory (unused when
run_updatereads the answers file, but kept for API symmetry withrender()).dest (pathlib.Path) – Destination directory containing the previously-generated project.
data (dict[str, Any] | None) – Answers/data overrides for template variables.
pretend (bool) – If True, don’t actually write files.
- Return type:
None