feat(insta-lab): card_renderer theme 폴백 가드 (HTML 없으면 default)

This commit is contained in:
2026-05-18 00:18:44 +09:00
parent 7640a2b4a8
commit 2915f2b697
2 changed files with 19 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import json
import logging
import os
import tempfile
from pathlib import Path
from typing import List
from jinja2 import Environment, FileSystemLoader, select_autoescape
@@ -67,6 +68,13 @@ async def render_slate(slate_id: int, template: str = "default/card.html.j2") ->
if not slate:
raise ValueError(f"slate {slate_id} not found")
env = _env()
# template 파일이 없으면 default로 폴백 (INSTA_DEFAULT_THEME가 import 안 된 theme이면 안전)
template_full = Path(_resolve_template_dir()) / template
if not template_full.exists():
logger.warning("Template '%s' 없음 → 'default/card.html.j2'로 폴백", template)
template = "default/card.html.j2"
tmpl = env.get_template(template)
pages = _build_pages(slate)
out_dir = _slate_dir(slate_id)