From f2ff3327c3f4021a2253d6db0ab0df5214c8e559 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 25 Dec 2025 00:04:40 +0545 Subject: [PATCH] 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. ``` --- devgen/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/devgen/utils.py b/devgen/utils.py index 5a02790..1f4e3b0 100644 --- a/devgen/utils.py +++ b/devgen/utils.py @@ -212,6 +212,13 @@ def load_template_env(sub_dir: str) -> Environment: 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]: config_path = Path.home() / ".devgen.yaml"