Skip to content

feat(core): Jinja2 .template processing and .append file convention #146

Description

@ulises-jeremias

Summary

Add CNA-parity file processing when loading template/extension layers:

  1. .template files — process with Jinja2 ({{ variable }}), strip the suffix from the output path.
  2. .append files — append content to an existing matching file instead of overwriting.

Variables come from scaffold context (projectName, customOptions answers from cpa.config.json, etc.).

CNA mapping

CNA: EJS .template + .append conventions in cna-templates / loaders (docs/AUTHORING.md in cna-templates).

CPA today: copy-only merge in create_python_app_core.loaders (copy_tree). Documented as a known limitation in cpa-templates docs (ARCHITECTURE.md, AUTHORING.md).

Acceptance criteria

  • .template files are rendered with Jinja2 and written without the .template suffix
  • Undefined variable policy documented (strict vs empty) and covered by tests
  • .append appends to the destination file when it exists; creates it when missing
  • Layer order still applies: template → addons → extend
  • Scaffold context exposes at least projectName and cpa.config.json custom option answers
  • Unit tests for .template, .append, and interaction with overwrite
  • Update cpa-templates AUTHORING docs once behavior ships (or open a follow-up there)

Out of scope (follow-ups)

  • [bracket]/ directory renaming
  • .if-* conditional file inclusion

Blocked by

none

Blocks

Better extension authoring in cpa-templates (today extensions must ship complete overlay files).

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corecreate-python-app-core enginearea:templates-contractTemplate catalog contract / cpa-templatesenhancementNew feature or requestpythonPython stack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions