Template Rendering Helper
Template Rendering Helper - focused on standalone template rendering.
Overview
This helper handles: - Standalone template rendering without full project initialization - Context preparation for templates - Platform-aware template variables - Template file operations
Classes
TemplateRenderingHelper
Helper for template rendering operations.
Methods
extract_template_variables
extract_template_variables(self, template_path: pathlib.Path) -> list[str]
Extract variables used in a template.
Parameters:
template_path(Path, required) - Path to template file
Returns: list
prepare_template_context
prepare_template_context(self, base_context: Optional[Dict[str, Any]] = None) -> specify_cli.models.project.TemplateContext
Prepare a complete template context for rendering.
Parameters:
base_context(Optional, optional) - Base context variables to include
Returns: TemplateContext
render_template_standalone
render_template_standalone(self, template_path: pathlib.Path, output_path: pathlib.Path, context_variables: Optional[Dict[str, Any]] = None, make_executable: bool = False) -> bool
Render a single template file without full project initialization.
Parameters:
template_path(Path, required) - Path to template fileoutput_path(Path, required) - Where to write rendered outputcontext_variables(Optional, optional) - Additional context variablesmake_executable(bool, optional) - Whether to make output file executable - Default:False
Returns: bool
validate_template_syntax
validate_template_syntax(self, template_path: pathlib.Path) -> tuple[bool, typing.Optional[str]]
Validate template syntax without rendering.
Parameters:
template_path(Path, required) - Path to template file
Returns: tuple