pjkm.core.templates.renderer

Template renderer: wraps Copier’s run_copy / run_update for project generation.

Classes

TemplateRenderer

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_update which reads .copier-answers.yml from dest to determine the original template. If that file is missing the caller should fall back to render() with overwrite=True.

Parameters:
  • template_path (pathlib.Path) – Path to the Copier template directory (unused when run_update reads the answers file, but kept for API symmetry with render()).

  • 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