processor
django_spire.core.management.commands.spire_startapp_pkg.processor
TemplateEngine
Renders template strings with variable replacements.
This class uses Python's string.Template to safely substitute placeholders in template files with actual values.
render
Renders a template string by replacing placeholders with values.
Parameters:
-
text(str) –Template string containing ${variable} placeholders.
-
replacements(dict[str, str]) –Dictionary mapping placeholder names to their values.
Returns:
-
str–Rendered string with all placeholders replaced.
Source code in django_spire/core/management/commands/spire_startapp_pkg/processor.py
TemplateProcessor
Processes template files for Django app generation.
This class handles the replacement of placeholders in template files and manages file renaming based on user configuration.
Initializes the processor with an engine and file system.
Parameters:
-
engine(TemplateEngine) –Template engine for rendering strings.
-
filesystem(FileSystem) –File system for file operations.
Source code in django_spire/core/management/commands/spire_startapp_pkg/processor.py
process_app_templates
Processes all template files in an app directory.
Replaces placeholders in .template files, renames them, and updates content in .py files based on user inputs.
Parameters:
-
directory(Path) –Root directory containing template files.
-
components(list[str]) –List of app path components.
-
user_inputs(dict[str, str] | None, default:None) –Optional dictionary of user-provided configuration values.
Source code in django_spire/core/management/commands/spire_startapp_pkg/processor.py
process_html_templates
Processes all HTML template files in a directory.
Replaces placeholders in .template files and renames them to remove the .template extension.
Parameters:
-
directory(Path) –Root directory containing HTML template files.
-
components(list[str]) –List of app path components.
-
user_inputs(dict[str, str] | None, default:None) –Optional dictionary of user-provided configuration values.