Template Engine

Template engine for rendering project files.

pypreset.template_engine.get_templates_dir()[source]

Get the directory containing built-in templates.

Return type:

Path

pypreset.template_engine.create_jinja_environment()[source]

Create a Jinja2 environment with the templates directory.

Return type:

Environment

pypreset.template_engine.get_template_context(config)[source]

Build the template context from a project configuration.

Parameters:

config (ProjectConfig)

Return type:

dict[str, Any]

pypreset.template_engine.render_template(env, template_name, context)[source]

Render a template with the given context.

Parameters:
Return type:

str

pypreset.template_engine.render_content(content, context)[source]

Render inline content (not from a template file).

Parameters:
Return type:

str

pypreset.template_engine.render_path(path_template, context)[source]

Render a path template (e.g., ‘src/{{ project.package_name }}’).

Parameters:
Return type:

str