Skip to content

Templates System

The template system allows you to generate files and directories from templates. It forms the foundation of Angreal’s project creation capabilities.

Angreal’s template system consists of:

  • Template Rendering - Generate files from templates
  • Directory Rendering - Process entire directories of templates
  • Context Generation - Create variables for templates
  • angreal.toml Format - Configure template variables and prompts

Templates use the Tera templating engine, which provides Jinja2-like syntax.

Component Description Documentation
render_template Render a single template file API Reference
render_directory Process a directory of templates API Reference
generate_context Create context variables for templates API Reference
angreal.toml Define template variables and prompts Format Reference

For a complete walkthrough of using templates, see the Template System Guide.

import angreal
import os
def create_project():
# Generate context for templates
context = angreal.generate_context(
template_path="templates/project",
interactive=True
)
# Render a directory of templates
angreal.render_directory(
source_directory="templates/project",
target_directory=context.get("project_name", "new-project"),
context=context
)