Templates API Reference¶
The audiomancer.templates module provides project template functionality.
Overview¶
templates
¶
Template management for project scaffolding.
get_template_dir() -> Path
¶
Get path to templates directory.
Returns:
| Type | Description |
|---|---|
Path
|
Path to src/audiomancer/templates/ |
get_template_variables(project_name: str, project_root: Path, sample_source: Path) -> dict[str, str]
¶
Get variables for template rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
Project name (alphanumeric, hyphens, underscores) |
required |
project_root
|
Path
|
Absolute path to project directory |
required |
sample_source
|
Path
|
Absolute path to sample source directory |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dict of variable names to string values for template substitution |
Raises:
| Type | Description |
|---|---|
ValueError
|
If validation fails |
render_template(template_path: Path, variables: dict[str, str]) -> str
¶
Render a template file with variable substitution.
Uses simple regex-based substitution: {{ variable_name }} Safe - no code execution like Jinja2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_path
|
Path
|
Path to template file (.template extension) |
required |
variables
|
dict[str, str]
|
Dict of variable_name -> value (all strings) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Rendered template string with variables replaced |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If template_path doesn't exist |
UnicodeDecodeError
|
If template is not UTF-8 |