feat(devgen): add custom template rendering function
- New Features: - Introduced `render_custom_template()` function to render Jinja2 templates from strings. - Enables dynamic template rendering without requiring file-based templates. ```
This commit is contained in:
1 file changed
+7
@@ -212,6 +212,13 @@ def load_template_env(sub_dir: str) -> Environment:
|
|||||||
return Environment(loader=FileSystemLoader(template_dir))
|
return Environment(loader=FileSystemLoader(template_dir))
|
||||||
|
|
||||||
|
|
||||||
|
def render_custom_template(template_str: str, **context) -> str:
|
||||||
|
"""Renders a Jinja2 template from a string."""
|
||||||
|
env = Environment()
|
||||||
|
template = env.from_string(template_str)
|
||||||
|
return template.render(**context)
|
||||||
|
|
||||||
|
|
||||||
def load_config() -> Dict[str, Any]:
|
def load_config() -> Dict[str, Any]:
|
||||||
config_path = Path.home() / ".devgen.yaml"
|
config_path = Path.home() / ".devgen.yaml"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user